Skip to content

Instantly share code, notes, and snippets.

@jaemyeong
Created August 30, 2017 08:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaemyeong/fc9cc0f7dca490195032f08722227d3f to your computer and use it in GitHub Desktop.
Save jaemyeong/fc9cc0f7dca490195032f08722227d3f to your computer and use it in GitHub Desktop.
Markup for Vivace
let attributedString = NSMutableAttributedString(string: "<green>1234</green>5678<green>91011</green>")
let storage = attributedString.mutableString
let startRange = storage.range(of: "<green>")
let endRange = storage.range(of: "</green>")
storage.deleteCharacters(in: endRange)
storage.deleteCharacters(in: startRange)
attributedString.addAttributes([NSForegroundColorAttributeName: UIColor.green], range: NSRange(location: startRange.location, length: endRange.location - startRange.length))
print(attributedString)
self.textLabel.attributedText = attributedString
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment