Last active
August 9, 2017 07:53
-
-
Save phynet/84b9e03941c4890895ac86f72416e63d to your computer and use it in GitHub Desktop.
Add color to a certain part of a string (or NSString)
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
func configureTextr() -> NSAttributedString{ | |
let text = "first string" | |
let aviso = "second string" | |
let mainText = text! + " " + aviso! | |
let attributeText = aviso | |
let range = (mainText as NSString).range(of: attributeText!) | |
let attributedString = NSMutableAttributedString(string:mainText) | |
attributedString.addAttribute(NSForegroundColorAttributeName, value: UIColor.rentaliaLightBlue(withAlpha: 1), range: range) | |
return attributedString | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment