Hi I am new to swift and I have implemented a picker view that alter the text in my UITextField.
However the keyboard cursor will still show up, is there any way to remove the keyboard cursor?
Hi I am new to swift and I have implemented a picker view that alter the text in my UITextField.
However the keyboard cursor will still show up, is there any way to remove the keyboard cursor?
Simple
Go to storyboard -> Select textfield -> properties -> set tint color to clear color
Or UITextField.appearance().tintColor = UIColor.clear
Implement this method in your UITextFieldDelegate
:
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
return false
}
This disables typing, copy&pasting and deleting.
If you prefer to not show the keyboard or cursor at all, you can avoid the textfield to become the first responder and show your custom picker instead:
func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
// Show your picker here, and return false to avoid showing keyboard
return false
}