Вы можете использовать NSString
replacingOccurrences(of:with:)
, чтобы вводить текст, как этот
Swift2
func textView(textView: UITextView, shouldChangeTextInRange range: NSRange, replacementText text: String) -> Bool {
let originText = textView.text as NSString
let replacingText = originText.stringByReplacingCharactersInRange(range, withString: text)
label.text = replacingText
return true
}
Swift3
func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
let originText = textView.text as NSString
let replacingText = originText.replacingCharacters(in: range, with: text)
label.text = replacingText
return true
}