How to set the range?
qiushuitian opened this issue · comments
qiushuitian commented
I mean original function like this:
attributedString.setAttributes([NSFontAttributeName: UIFont.boldSystemFont(ofSize: 18)], range: dontRange)
kmohsin11 commented
You can set range by calling the method setAttributes(attributes: TextAttributes , range:)
let baseString = "Don't use magic numbers."
let attributedString = NSMutableAttributedString(string: baseString, attributes: nil)
let dontRange = (attributedString.string as NSString).range(of: "Don't")
let attr = TextAttributes()
.font(UIFont.systemFont(ofSize: 10))
.foregroundColor(.white)
attributedString.setAttributes(attr, range: dontRange)
Damien commented
Thanks @kmohsin11 :)