To compare the tap areas of two similar buttons,
the sample below is run in the preview canvas for an iPhone with iOS 26.
Button 1 is outside the toolbar,
whereas Button 2 is inside the toolbar.
When tapping outside Button 1 near its edge,
unexpectedly the action is triggered.
When tapping inside Button 2 near its edge,
unexpectedly the action is not triggered.
Why are the tap areas of similar buttons not similar ?
How to make a tap area have the edge of the button ?
.
.
import SwiftUI
struct SampleView: View {
var body: some View {
NavigationStack {
Button(action: self.action) {
Text("Button 1")
}
.buttonStyle(.glassProminent)
.toolbar {
ToolbarItem {
Button(action: self.action) {
Text("Button 2")
}
.buttonStyle(.glassProminent)
}
}
}
}
private func action() {
print("Action Triggered !")
}
}
#Preview {
SampleView()
}