I just wanted to know how could i change the background color of an NSAttributedString, i can see the background being white all the time, but i want to make it black.
Is that possible?? Many thanks!
I think you want NSBackgroundColorAttributeName. Such as:
[mutableAttributedString addAttribute:NSBackgroundColorAttributeName value:[UIColor yellowColor] range:selectedRange];
For swift 3.x attributedString.addAttribute(NSBackgroundColorAttributeName, value: yourColor, range: NSMakeRange(0, tillLocation))
Helpfull link - Different way to attribute a string
最好的计划是在具有黑色背景的视图上绘制字符串。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.