I would like to have the follow result:
I tried to use this code, but no success:
func textView(textView: UITextView, shouldChangeTextInRange range: NSRange, replacementText text: String) -> Bool {
if range.location > 159 {
let attributedString = NSMutableAttributedString(string: bioTextView.text)
let range2 = (bioTextView.text as NSString).rangeOfString(bioTextView.text)
attributedString.addAttributes([NSForegroundColorAttributeName: UIColor.flatRedColor(), NSFontAttributeName: UIFont(name: "Helvetica Neue", size: 14)!], range: range2)
bioTextView.attributedText = attributedString
}
}
I saw in this post: Finding index of character in Swift String
That I should not convert to NSString, because can bug with emoji
PS: Sorry about my English, I'm still learning.