I have a custom SwiftUI
View where in an HStack
I have two VStack
s on opposite ends.
I need each to have its own double-tap gesture to show and hide the items in the VStack
.
Here is what I have tried:
@State var displayRewind = false
VStack {
Image("rewind")
.frame(width: 74, height: 32, alignment: .center)
.foregroundColor(Color.white)
.opacity(self.displayRewind ? 1 : 0)
Text("x seconds")
.opacity(self.displayRewind ? 1 : 0)
}
.onTapGesture(count: 2) {
withAnimation {
displayRewind.toggle()
}
DispatchQueue.main.asyncAfter(deadline: .now()+1) {
withAnimation {
displayRewind.toggle()
}
}
}
Right now with this, nothing happens. If I remove the opacity on the Text, I see the text and I can double-tap to reveal the image.
The goal would be to show and hide these together.