I need to create a random string with format which can convert any string(including parenthesis() to another color on swift: for example:
"Hey (Hey)": First part 'Hey' is fine, but I want to change : (Hey) to a different color. Same goes if I choose another string.
"Hey (What's Up) ...."
And tried the following:
let color = UIColor(white: 0.2, alpha: 1)
let attributedTextCustom = NSMutableAttributedString(string:"\( format:) %@", attributes: [NSAttributedString.Key.font: UIFont(name:"AvenirNext-Medium", size: 16)!, NSAttributedString.Key.foregroundColor: color])
attributedTextCustom.append(NSAttributedString(string: " (\(String())", attributes: [NSAttributedString.Key.font: UIFont(name: "AvenirNext-Regular", size: 12)!, NSAttributedString.Key.foregroundColor: UIColor.lightGray]))
cell.nameLabel.attributedText = attributedTextCustom
Aucun commentaire:
Enregistrer un commentaire