2

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?

Cœur
  • 37,241
  • 25
  • 195
  • 267
4ntoine
  • 19,816
  • 21
  • 96
  • 220
  • Possible duplicate of [UILabel: Custom underline color?](https://stackoverflow.com/questions/22419945/uilabel-custom-underline-color) – Cœur Mar 21 '18 at 15:42

1 Answers1

3

Yes. Use NSUnderlineColorAttributeName to set the underline color.

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