Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. extension NSMutableAttributedString {
  2. func apply(attribute: [NSAttributedString.Key: Any], subString: String) {
  3. if let range = self.string.range(of: subString) {
  4. self.apply(attribute: attribute, onRange: NSRange(range, in: self.string))
  5. }
  6. }
  7. func apply(attribute: [NSAttributedString.Key: Any], onRange range: NSRange) {
  8. if range.location != NSNotFound {
  9. self.setAttributes(attribute, range: range)
  10. }
  11. }
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement