To make a toolbar button that has the maximum width, I proceed as shown below with iOS 26.
The appearance of the button is as expected, but its behavior is incorrect.
The action is not triggered when tapping within the button, but outside its text.
How to make the action triggered when tapping anywhere within the button ?
import SwiftUI
struct SampleView: View {
var body: some View {
NavigationStack {
Text("")
.toolbar {
ToolbarItem(placement: .bottomBar) {
Button(role: .confirm, action: self.action) {
Text("Action")
}
.frame(maxWidth: .infinity)
}
}
}
}
private func action() {
print("Action Triggered !")
}
}
#Preview {
SampleView()
}