swift 5.0富文本

let myMutableString = NSMutableAttributedString(string: "100 Gained", attributes: [NSAttributedString.Key.font:UIFont(name: "Georgia", size: 18.0)!])
        myMutableString.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor.purple, range: NSRange(location:0,length:myMutableString.length - 7))
 // set label Attribute
countL.attributedText = myMutableString
对上述的代码,有任何疑问,可以在下方留言。 也可以给我发邮件咨询:673658917@qq.com 或者是直接加qq:673658917 转载请注明出处,谢谢合作。 睡觉舒服,那是给死人准备的,加油吧,一年后你会感谢现在的自己的。
原文地址:https://www.cnblogs.com/lishanshan/p/14549233.html