I'm trying to limit the maximum lines of my textview to 2 lines. Ive tried:
This allows returns on the 3rd line
func textViewDidChange(textView: UITextView) {
let numLines:CGFloat = textView.contentSize.height/textView.font.lineHeight;
if (numLines > 2.999999)
{
textView.text = textView.text.substringToIndex(advance(textView.text.endIndex, -1))
}
}
This has some weird behavior on returns
textView.textContainer.maximumNumberOfLines = 2;
Any suggestions on how I can limit my textview to two lines?