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

 

posted @ 2021-03-17 14:37  狼狼a够  阅读(1139)  评论(0编辑  收藏  举报