I have two buttons next to each other. One is for starting a recording, one is for playing. When I click the play button, I see "play clicked" logged. When I click the record button, nothing happens. When I add a letter to the record button text, it's logged just fine.
Why can't I use a button with empty text in SwiftUI?
Button(action: {
print("record clicked")
}) {
Text("")
}
.frame(width: 55, height: 55)
.background(Color.red)
.cornerRadius(9999)
Button(action: {
print("play clicked")
}) {
Image(systemName: "play")
.foregroundColor(.white)
.font(.system(size: 30))
}
.frame(width: 55, height: 55)
.background(Color.green)
.cornerRadius(9999)
They determine tappable area for button by label content, but it is almost zero for empty text, so just make it remarkable, like
Button(action: {
print("record clicked")
}) {
Text("")
.padding() // << this !!
}
Tested as worked with Xcode 13 / iOS 15
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