Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/118.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在NSAttributedString(ios)中为下划线样式应用颜色?_Ios_Nsattributedstring - Fatal编程技术网

如何在NSAttributedString(ios)中为下划线样式应用颜色?

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

假设我在NSAttributedString中添加下划线样式:

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

是否可以在不更改文本颜色的情况下将颜色(不仅仅是下划线样式)应用于下划线?

是。使用
NSUnderlineColorAttributeName
设置下划线颜色

[attrStr addAttribute:NSUnderlineColorAttributeName value:[UIColor redColor] range:range];
可能重复的