3

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?

Wain
  • 118,658
  • 15
  • 128
  • 151
OscarTheGrouch
  • 2,374
  • 4
  • 28
  • 39

2 Answers2

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
0

It's part of NSAttributedString UIKitAdditions

Abizern
  • 146,289
  • 39
  • 203
  • 257