I am presenting a toolbar on top of my keyboard to dismiss the keyboard using the following modifier:
.toolbar {
ToolbarItemGroup(placement: .keyboard) {
Spacer()
Button {
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
} label: {
Image(systemName: "keyboard.chevron.compact.down.fill")
}
}
}
Is there anyway to change the color of the toolbar background and maybe give it upper right and upper left corner radius? So far I can only change the color of the symbol or text that I add to the toolbar but not the toolbar background itself.

You could also just create a view of fixed length that lies at the bottom of the ToolbarItemGroup.
(Using maxWidth will not work for some reason.)
.toolbar {
ToolbarItemGroup(placement: .keyboard) {
Text("save")
.frame(width: UIScreen.main.bounds.width)
.frame(height: 45)
.background {
RoundedRectangle(cornerRadius: 10)
.fill(Color.customWhite.opacity(0.1))
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With