簡體   English   中英

如何在NSAttributedString(ios)中為下划線樣式應用顏色?

[英]How to apply color for underline style in NSAttributedString (ios)?

假設我要在NSAttributedString中添加下划線樣式:

[attrStr addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:range];

是否可以將顏色(不僅是下划線樣式)應用於下划線而不更改文本顏色?

是。 使用NSUnderlineColorAttributeName設置下划線顏色。

[attrStr addAttribute:NSUnderlineColorAttributeName value:[UIColor redColor] range:range];

暫無
暫無

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

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