0

このコードを使用して、ビューの 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 メソッドがないことです。どうすればいいですか?

4

1 に答える 1

1

IBOutletラベルの を作成してviewDidLoad、属性付き文字列を構成するだけです。この効果は、Interface Builder でも追加できると思います。

于 2013-09-20T04:11:12.080 に答える