func setTextColorWhihString(one:String,two:String,font:CGFloat) -> NSMutableAttributedString
{
let text = NSMutableAttributedString(string: "\(one)", attributes: [
NSForegroundColorAttributeName: UIColor(rgba: "#333333"),
NSFontAttributeName:UIFont.systemFontOfSize(font)
])
text.appendAttributedString(NSMutableAttributedString(string: "\(two)" , attributes: [NSForegroundColorAttributeName : KEY_COLOR_NAV , NSFontAttributeName : UIFont.systemFontOfSize(font)]))
return text
}

本文介绍了一个Swift函数,该函数用于创建带有不同颜色和相同字体的NSAttributedString。通过传入两个字符串及字体大小参数,可以实现文本颜色的区分显示,并应用于iOS应用开发中。
1万+

被折叠的 条评论
为什么被折叠?



