Skip to content

Instantly share code, notes, and snippets.

@hellensoloviy
Created January 23, 2026 11:43
Show Gist options
  • Select an option

  • Save hellensoloviy/99e4edbdfdf9d82ffc5c7c94be449e5c to your computer and use it in GitHub Desktop.

Select an option

Save hellensoloviy/99e4edbdfdf9d82ffc5c7c94be449e5c to your computer and use it in GitHub Desktop.
ToolBar button with popoverTip issue in SwiftUI, popoverTip is not showing fix variant
//
// ExpenseList.swift
// ExpensesListApp
//
// Created by Hellen Soloviy on 21.01.2026.
//
import SwiftUI
import TipKit
struct ExpenseCell: View {
var expense: Expense
var body: some View {
Text("Some text")
}
}
struct ExpenseList: View {
var expenses: [Expense]
var addExpenseTip = AddExpenseTip()
var body: some View {
NavigationStack {
List {
ForEach(expenses) { obj in
ExpenseCell(expense: obj)
}
}
}
.navigationTitle("Expenses")
.navigationBarTitleDisplayMode(.large)
.toolbar {
/// This will not work when adding a popoverTip as there is a
/// system handled label creation, and its not direct enoungh for popoverTip to use it.
Button("Add expense", systemImage: "plus")
{
/// action here
}
.popoverTip(addExpenseTip)
/// This way will provide a working solution.
/// Mostly the same but this is a more generic init of the the same button and works a little differently inside.
/// But, while using it, be aware that this init doesn't have a system generated accessibilityLabel
/// so we need to add it manually
Button {
/// action here
} label: {
Image(systemName: "plus")
}
.accessibilityLabel("Add new expense")
.popoverTip(addExpenseTip)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment