Saint Robson
Saint Robson

Reputation: 5525

How to create attribute for Underline on UILabel?

I already have this attribute on my code, but how to add attribute for underline?

NSDictionary *attrs = [NSDictionary dictionaryWithObjectsAndKeys: 
boldFont, NSFontAttributeName, foregroundColor, NSForegroundColorAttributeName, nil];

Upvotes: 2

Views: 5551

Answers (1)

Marcelo
Marcelo

Reputation: 9944

Just add a NSUnderlineStyleAttributeName key with @(NSUnderlineStyleSingle) as a value:

NSDictionary *attrs = @{ NSFontAttributeName : boldFont, 
                         NSForegroundColorAttributeName : foregroundColor,
                         NSUnderlineStyleAttributeName : @(NSUnderlineStyleSingle) };

Upvotes: 13

Related Questions