美文网首页
Swift rang to NSRange

Swift rang to NSRange

作者: _风雨 | 来源:发表于2021-09-24 10:47 被阅读0次

主要代码

let location = att.string.range(of: "\(count)")

NSRange(location, in: att.string)
let count: Int = 56
        let att = NSMutableAttributedString(string: "\(count)件礼物")
        guard let location = att.string.range(of: "\(count)") else {
            return
        }
        let range = NSRange(location, in: att.string)
        att.yy_setAttribute(NSAttributedString.Key.font.rawValue, value: UIFont.systemFont(ofSize: 13), range: range)
        att.yy_setAttribute(NSAttributedString.Key.foregroundColor.rawValue, value: UIColor(colorType: .C34), range: range)
        haveLightLabel.attributedText = att

相关文章

网友评论

      本文标题:Swift rang to NSRange

      本文链接:https://www.haomeiwen.com/subject/vlxzgltx.html