Created
December 21, 2017 14:04
-
-
Save robnadin/5991267abf8b8e68d006459c249f55c3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UITextField { | |
func textRange(from range: NSRange) -> UITextRange? { | |
guard | |
let startPosition = position(from: beginningOfDocument, offset: range.location), | |
let endPosition = position(from: startPosition, offset: range.length) else { | |
return nil | |
} | |
return textField.textRange(from: startPosition, to: endPosition) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment