OscarTheGrouch
OscarTheGrouch

Reputation: 2384

Letterpress effect for UILabel in iOS 7 SDK

In the WWDC 2013 videos they show that a developer can use a letterpress effect on text. Does anyone have any example code of how to do this/how to do this with a UILabel?

Upvotes: 3

Views: 4051

Answers (2)

Amit
Amit

Reputation: 836

They've made it pretty simple now.

//Use any font you want or skip defining it
UIFont* font = [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline];

//Use any color you want or skip defining it
UIColor* textColor = [UIColor blueColor];

NSDictionary *attrs = @{ NSForegroundColorAttributeName : textColor,
                                NSFontAttributeName : font,
                          NSTextEffectAttributeName : NSTextEffectLetterpressStyle};

NSAttributedString* attrString = [[NSAttributedString alloc]
                                   initWithString:note.title
                                       attributes:attrs];

myTextLabel.attributedText = attrString;

Upvotes: 17

Abizern
Abizern

Reputation: 150745

It's part of NSAttributedString UIKitAdditions

Upvotes: 0

Related Questions