Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // SGColorExtension.swift
- //
- // Created by Sudhir Gadhvi on 10/01/19.
- // Copyright © 2019 Sudhir. All rights reserved.
- //
- func colorWord(word _word: String, inString _string: String, with _color: UIColor)-> NSMutableAttributedString?
- {
- let main_string = _string
- let string_to_color = _word
- let range = (main_string as NSString).range(of: string_to_color)
- let attribute = NSMutableAttributedString.init(string: main_string)
- attribute.addAttribute(NSAttributedString.Key.foregroundColor, value: _color , range: range)
- return attribute
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement