我有一个应用程序,我使用此代码在视图中向 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;
但我有另一个应用程序,我想将它添加到表格视图单元格中的单个标签中。问题是它是一个静态表格视图,我没有设置文本的 cellForRowAtIndexPath 方法。我该怎么做?