If I already have a button whose font size is defined by the .font() modifier like below:
Button("Hello"){}
.font(.system(size: 10))
How can I use a ButtonStyle with .buttonStyle() to decide the size of this button?
struct CustomButtonStyle: ButtonStyle {
func makeBody(configuration: Configuration) -> some View {
let size = 2 * configuration.label.fontSize // Something like this
configuration.label
.frame(width: size, height: size)
.background(.red)
}
}
Or is there some alternatives to this approach? I tried using .padding() directly. But it don't work properly. As you can see in above screenshot, different sizes were generated because the different sizes of SF Symbols.
func makeBody(configuration: Configuration) -> some View {
configuration.label
.padding()
.background(.red)
}

