Created
August 30, 2017 08:59
-
-
Save jaemyeong/fc9cc0f7dca490195032f08722227d3f to your computer and use it in GitHub Desktop.
Markup for Vivace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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