Enabling the iOS Clear Button in NativeScript
If you’d like to use the iOS clear button on a NativeScript text field, it’s actually quite easy. All you have to do is enable it on the native iOS UITextField:
Values for this property come from UITextField.ViewMode. However, there area couple caveats:
- Just enabling the clear button will cause your input text to go under the clear button.
- ngModel will make the clear button disappear.
To fix these, you must adjust the right padding when the field is focused, and avoid ngModel. Here’s a simple way to do it in NativeScript + Angular:
Hopefully those of you using NativeScript Core or Vue find that easy to translate!