I'd like to change default MenuButton style. I want to use the default button color instead of Color.gray
MenuButton("Actions") {
Button(action: {
}, label: { Text("Action 1") })
Button(action: {
}, label: { Text("Action 2") })
}
.menuButtonStyle(BorderlessButtonMenuButtonStyle())
.background(RoundedRectangle(cornerRadius: 5).foregroundColor(Color.gray))
I try to change the default style that looks like
to the style like button
I am using it like this:
.foregroundColor(.accentColor)
.background(Color(UIColor.systemBackground))
Created Style like this:
struct MainButtonStyle: PrimitiveButtonStyle {
let minWidth: CGFloat
let minHeight: CGFloat
func makeBody(configuration: Self.Configuration) -> some View {
Button(configuration)
.frame(minWidth: minWidth, minHeight: minHeight)
.font(.body)
.foregroundColor(.accentColor)
.background(Color(UIColor.systemBackground))
.buttonStyle(BorderlessButtonStyle())
.cornerRadius(5)
}
}
Use case:
Button(action: { }, label: {
Image(systemName: "map")
})
.buttonStyle(MainButtonStyle(minWidth: 30, minHeight: 30))
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