UIlabel 富文本拼接

        let t_icon  = UIImage.init(named: "recommend")
        //商品现价
        let cp = "¥ " + (data?["price"] as! String?)!

        currentprice.attributedText = UILabel.fixAttributedStr(withTexts: [cp], textColors: [UIColor.red], textfonts: [UIFont.systemFont(ofSize: 10)], image: nil, insert: nil, imageBounds: CGRect.init(x: 0, y: 5, width: 15, height: 15), lineSpacing: 5)


        let currentPriceAttri = NSMutableAttributedString.init(string: stra)
        currentPriceAttri.addAttribute(NSForegroundColorAttributeName, value: UIColor.red, range: NSRange.init(location: 0, length: stra.characters.count))

推荐阅读更多精彩内容