I was trying to hide view but noticed that view.hidden()
will only hide the view but but the space remains.
I also tried some of the suggestions on this link
CodePudding user response:
I created an extension function as below
extension View {
@ViewBuilder func hiddenConditionally(isHidden: Binding<Bool>) -> some View {
isHidden.wrappedValue ? self : self.hidden() as? Self
}
}
and you can call it as below
TextField("Pin", text: $pin)
.hiddenConditionally(isHidden: $showPinField)