Letterpress effect for UILabel in iOS 7 SDK

4k Views Asked by At

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?

2

There are 2 best solutions below

3
On

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;
1
On