簡體   English   中英

更改NSAttributedString上的背景顏色

[英]Changing Background color on NSAttributedString

我只是想知道如何更改NSAttributedString的背景顏色,我可以看到背景一直是白色,但我想讓它變黑。

那可能嗎?? 非常感謝!

我想你想要NSBackgroundColorAttributeName。 如:

[mutableAttributedString addAttribute:NSBackgroundColorAttributeName value:[UIColor yellowColor] range:selectedRange];

對於swift 3.x attributedString.addAttribute(NSBackgroundColorAttributeName, value: yourColor, range: NSMakeRange(0, tillLocation))

有用的鏈接 - 屬性字符串的不同方式

最好的計划是在具有黑色背景的視圖上繪制字符串。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM