I'm attempting to change the .textFieldStyle modifier for a TextField based upon whether my View is editing. I declare var isEditing: Bool, set this in the parent View and check against this in the body. My code:
TextField("Type a Name", text: $name) {
myManagedObjectObserved.attribute = name
}
.textFieldStyle(isEditing ? RoundedBorderTextFieldStyle() : PlainTextFieldStyle())
The compiler complains with the following build time error...
Result values in '? :' expression have mismatching types 'RoundedBorderTextFieldStyle' and 'PlainTextFieldStyle'
Don't understand why? Is anyone able to explain please?