Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.58 KB | None | 0 0
  1.  let attrString = NSMutableAttributedString(string: text + phone, attributes: nil)
  2.  let rangeText = (attrString.string as NSString).range(of: text)
  3.  let rangePhone = (attrString.string as NSString).range(of: phone)
  4.        
  5.  attrString.setAttributes([NSAttributedStringKey.foregroundColor: UIColor.red], range: rangeText)
  6.        
  7.  attrString.setAttributes([NSAttributedStringKey.foregroundColor: UIColor.brown,
  8.                                               NSAttributedStringKey.underlineStyle: NSUnderlineStyle.styleSingle.rawValue],
  9.                                  range: rangePhone)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement