Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extension NSMutableAttributedString {
- func apply(attribute: [NSAttributedString.Key: Any], subString: String) {
- if let range = self.string.range(of: subString) {
- self.apply(attribute: attribute, onRange: NSRange(range, in: self.string))
- }
- }
- func apply(attribute: [NSAttributedString.Key: Any], onRange range: NSRange) {
- if range.location != NSNotFound {
- self.setAttributes(attribute, range: range)
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement