import SwiftUI
import PlaygroundSupport
struct ContentView: View {
@State var count = 1
var body: some View {
VStack {
Color.clear
.onTapGesture {
count += 1
}
Text("Counter: \(count)")
}
}
}
PlaygroundPage.current.setLiveView(ContentView())
The above counter doesn't work for Color.clear
in the playground app. However, if the Color.clear
were replaced by any color that's not transparent (e.g. Color.red
) it will work.
I don't understand why transparent views are not interactable like other views. Make transparent views interactable can be very useful (e.g. provide a larger tolerance space to let visually-small controls recognise gestures).