I am using the following code to change the foreground color
and font
of a attribute string using Swift
. But the Font changing perfectly without any problem but the foreground color
is not changing
var checklistText = NSMutableAttributedString()
checklistText = NSMutableAttributedString(string: "\(lblChecklistName.text!),\(checklistName)")
checklistText.addAttribute(NSFontAttributeName,
value: UIFont(
name: "Helvetica",
size: 11.0)!,
range: NSRange(location: lblChecklistName.text!.length(), length: checklistName.length()))
checklistText.addAttribute(NSForegroundColorAttributeName, value: UIColor.redColor(), range: NSRange(location: lblChecklistName.text!.length(), length: checklistName.length()+1))
lblChecklistName.attributedText = checklistText
length
, i use.characters.count
– Unwarrantable