let rangeMain = (textView!.text! as NSString).range(of: (textView!.text! as NSString) as String)
let rangeGreen = (textView!.text! as NSString).range(of: "a")
let rangeBlue = (textView!.text! as NSString).range(of: "b")
let rangeGray = (textView!.text! as NSString).range(of: "c")
let attributedString = NSMutableAttributedString(string: textView!.self.text!)
attributedString.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor.black, range: rangeMain)
attributedString.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor.blue, range: rangeBlue)
attributedString.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor.green, range: rangeGreen)
attributedString.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor.gray, range: rangeGray)
textView!.attributedText = attributedString
Вы пробовали что-то подобное?
Пришлось изменить указанный c текст (символы: a, b, c, которые вы можете переименовать, чтобы они были) .. .