4ntoine
4ntoine

Reputation: 20422

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

Let's say i'm adding underline style in NSAttributedString:

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

Is it possible to apply color (not only underline style) to underline without changing text color?

Upvotes: 2

Views: 919

Answers (1)

user4151918
user4151918

Reputation:

Yes. Use NSUnderlineColorAttributeName to set the underline color.

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

Upvotes: 3

Related Questions