Created
June 28, 2017 12:52
-
-
Save Morbix/cc8807d21a383d639143acf9cf580138 to your computer and use it in GitHub Desktop.
UITextField with multiple lines
This file contains hidden or 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 { | |
// Works only if the UITextField don't have the focus and have some text, | |
// so prefer call this in the didEndEditing event. | |
func setNumberOfLines(_ numberOfLines: Int, lineBreakMode: NSLineBreakMode) { | |
self.subviews.forEach { subview in | |
guard let label = subview as? UILabel else { return } | |
label.lineBreakMode = lineBreakMode | |
label.numberOfLines = numberOfLines | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment