How do I add letterpress effect for static uitableview cell

1k Views Asked by At

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?

1

There are 1 best solutions below

1
On BEST ANSWER

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.