I am creating a text control which accepts optional text value. If the value is provided I would like to show TextField control otherwise use Text Control. Can you please guide me how can I rebind already binded value to a text field
struct TextBoxControl: View {
var text : String
@Binding var value : String?
var body: some View {
if (value == nil )
{
Text(text)
}
else
{
TextField("Enter value", text: $value!)
}
}
}
2
Answers
Great I found a solution
It is much simpler for your case, just