Solution for some button styles
The following solution works for any primitive button style except :
.automatic, .borderedProminent, .glassProminent and .plain
I did not find the reason why it does not work for these styles :
Either I missed something or there is a limitation.
.toolbar {
ToolbarItem(placement: .bottomBar) {
Button(action: self.action) {
Text("Action")
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
.buttonStyle(.borderless)
}
}
.
.
.
Workaround for other button styles
The following workaround works for these primitive button styles :
.borderedProminent and .glassProminent
But this workaround requires 1 height and 4 padding constants,
which may depend on the device type and the iOS version.
.safeAreaBar(edge: .bottom) {
Button(action: self.action) {
Text("Action")
.frame(maxWidth: .infinity, maxHeight: 34)
}
.buttonStyle(.glassProminent)
.padding(.init(top: 0, leading: 28, bottom: 28, trailing: 28))
}
.ignoresSafeArea()