如何为静态uitableview单元格添加凸版效果

时间:2013-09-20 03:58:24

标签: ios uitableview letterpress

我有一个应用程序,我使用此代码在视图中为NSStrings添加凸版效果:

//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;

但我有另一个应用程序,我想将它添加到tableview单元格中的单个标签。问题是它是一个静态的tableview,我没有设置文本的cellForRowAtIndexPath方法。我该怎么做呢?

1 个答案:

答案 0 :(得分:1)

您可以为标签创建IBOutlet,并在viewDidLoad上配置属性字符串。我相信您也可以通过Interface Builder添加此效果。

相关问题