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?
Asked
Active
Viewed 4,029 times
3
-
Can you please accept the answer so it helps other as well? Thanks. – Amit Oct 11 '13 at 19:40
2 Answers
17
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;

Amit
- 836
- 8
- 19
-
-
2Yes. You can use - (void)setAttributedTitle:(NSAttributedString *)title forState:(UIControlState)state – Amit Oct 23 '13 at 20:14
-
Thank you, it's working now I had a related error which prevented it from showing – Adam Carter Oct 24 '13 at 00:56