我正在尝试自定义文本视图的显示,通过使用粗体和其他颜色的特定行 - 但我似乎无法弄清楚如何为文本添加另一种颜色。我有这个功能;
func attributedText()->NSAttributedString{
let string = "These Terms and Conditions are effective on July 24, 2016.\n\nBye " as NSString
var attributedString = NSMutableAttributedString(string: string as String, attributes: [NSFontAttributeName:UIFont.systemFontOfSize(12.0)])
let boldFontAttribute = [NSFontAttributeName: UIFont.boldSystemFontOfSize(12.0)]
attributedString.addAttributes(boldFontAttribute, range: string.rangeOfString("These Terms and Conditions are effective on July 24, 2016."))
attributedString.addAttributes(boldFontAttribute, range: string.rangeOfString("PLEASE NOTE:"))
// 4
return attributedString
}
我还需要为文本设置颜色吗?