My problem:
I want to call a function when my customView clicked
So I use @State variable to observe the click action from my custom view. But the problem is my value changed but didSet function not triggered
My code:
Main struct:
@State var buttonClicked : Bool = false {
didSet{
needToCallMyFunction() // not triggered
}
}
Custom struct:(for my customview)
@Binding var isClicked : Bool
someview
.onTapGesture(perform: {
print("custom clicked")
isClicked.toggle()
})