EDIT: Turns out this is an issue with macOs.
- Issue with Buttons in SwiftUI on MacOS
EDIT 2: As Asmari mention below, you can use PlainButtonStyle:
var body: some View {
VStack{
Button(action: {
print("Pressed!")
}){
Text("Press me")
.frame(width: 100, height: 100)
.foregroundColor(Color.black)
.background(Color.red)
.clipShape(Circle())
}.buttonStyle(PlainButtonStyle())
}.frame(width: 300, height: 500)
}
}
or use a custom style:
struct BlueButtonStyle: ButtonStyle {
func makeBody(configuration: Self.Configuration) -> some View {
configuration.label
.frame(width: 100, height: 100)
.foregroundColor(Color.black)
.background(Color.red)
.clipShape(Circle())
}
}
struct ContentView: View {
var body: some View {
VStack{
Button(action: {
print("Pressed!")
}){
Text("Press me")
}.buttonStyle(BlueButtonStyle())
}.frame(width: 300, height: 500)
}
}