如何在NSAttributedString(ios)中为下划线样式应用颜色?
假设我在NSAttributedString中添加下划线样式:如何在NSAttributedString(ios)中为下划线样式应用颜色?,ios,nsattributedstring,Ios,Nsattributedstring,假设我在NSAttributedString中添加下划线样式: [attrStr addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:range]; 是否可以在不更改文本颜色的情况下将颜色(不仅仅是下划线样式)应用于下划线?是。使用NSUnderlineColorAttributeName设置下划线颜色 [attrStr addAttribute:NSUnderlineColorAtt
[attrStr addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:range];
是否可以在不更改文本颜色的情况下将颜色(不仅仅是下划线样式)应用于下划线?是。使用
NSUnderlineColorAttributeName
设置下划线颜色
[attrStr addAttribute:NSUnderlineColorAttributeName value:[UIColor redColor] range:range];
可能重复的