Skip to content

Instantly share code, notes, and snippets.

@fatihyildizhan
Created April 28, 2020 12:15
Show Gist options
  • Save fatihyildizhan/ac5f476aebd306b0580a1fa069f153a3 to your computer and use it in GitHub Desktop.
Save fatihyildizhan/ac5f476aebd306b0580a1fa069f153a3 to your computer and use it in GitHub Desktop.
Force to lower or uppercase on Swift
func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool {
if textField.isEqual(textFieldBodrum) {
textFieldBodrum.text = (textField.text as NSString).stringByReplacingCharactersInRange(range, withString: string.lowercaseString)
return false
} else if textField.isEqual(textFieldYalikavak) {
textFieldYalikavak.text = (textField.text as NSString).stringByReplacingCharactersInRange(range, withString: string.uppercaseString)
return false
}
return true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment