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?
You can create an
IBOutlet
for your label and onviewDidLoad
you just configure the attributed string. I believe that you can add this effect via Interface Builder too.