Created
January 9, 2019 01:27
-
-
Save geek1706/ae1d4505692b536d1a17262f6e287fbc to your computer and use it in GitHub Desktop.
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 setRequired() { | |
guard var labelText = self.text else { return } | |
if labelText.range(of: "*") == nil { | |
labelText = labelText + "*" | |
} | |
let range = (labelText as NSString).range(of: "*") | |
let attributedString = NSMutableAttributedString(string: labelText) | |
attributedString.addAttributes([.foregroundColor: UIColor.red], range: range) | |
self.attributedText = attributedString | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment