0

I have an app where I use this code to add letterpress effect to NSStrings in a view:

//NSMutableAttributedString

NSString *nameString = [NSString stringWithFormat:@"Nombre: %@", [[jsonArray objectAtIndex:0] objectForKey:@"nombre"]];
NSString *addressString = [NSString stringWithFormat:@"Direccion: %@", [[jsonArray objectAtIndex:0] objectForKey:@"direccion"]];

NSMutableAttributedString *restName = [[NSMutableAttributedString alloc] initWithString:nameString];
NSMutableAttributedString *addressName = [[NSMutableAttributedString alloc] initWithString:addressString];    

[restName addAttributes:@{ NSTextEffectAttributeName : NSTextEffectLetterpressStyle, NSFontAttributeName: [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline] } range:NSMakeRange(0, restName.length)];
[addressName addAttributes:@{ NSTextEffectAttributeName : NSTextEffectLetterpressStyle, NSFontAttributeName: [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline] } range:NSMakeRange(0, addressName.length)];

self.topVC.restaurantName.attributedText = restName;
self.topVC.restaurantAddress.attributedText = addressName;

but I have another app where I want to add it to a single label in a tableview cell. The thing is that its a static tableview, and i dont have a cellForRowAtIndexPath method where I set the text. How do I go about it?

Wain
  • 118,658
  • 15
  • 128
  • 151
marciokoko
  • 4,988
  • 8
  • 51
  • 91

1 Answers1

1

You can create an IBOutlet for your label and on viewDidLoad you just configure the attributed string. I believe that you can add this effect via Interface Builder too.

Marcelo
  • 9,916
  • 3
  • 43
  • 52
  • I havent been able to find the letterpress, in what i believe would be the Attributes Inspector for my UILabel. Have you seen it? – marciokoko Sep 24 '13 at 23:14