文字列があります...別の色でShare Pictures
表示したいのですが、以前は文字列のその部分の色を変更していましたが、次の文字列を使用して設定すると機能しません。これを行う?Share
NSMutableAttributedString
cell.textLabel.text
このようにそれは機能しません。
NSMutableAttributedString *string3 = [[NSMutableAttributedString alloc]initWithString:@"Share pictures "];
[string3 addAttribute:NSForegroundColorAttributeName value:[UIColor orangeColor] range:NSMakeRange(0, 4)];
NSString *tempStr3 = @"with your friends.";
NSString *finalString3 = [NSString stringWithFormat:@"%@%@" , string3, tempStr3];
[menuTextArray addObject:finalString3];
そして、テーブルビューのデータソースメソッド。
cell.textLabel.text = [menuTextArray objectAtIndex:indexPath.row];
あなたはNSMutableAttributedString
あなたのmenuTextArray
:にのみ追加する必要があります
NSMutableAttributedString *yourString = [[NSMutableAttributedString alloc]initWithString:@"Share pictures with your friends"];
[yourString addAttribute:NSForegroundColorAttributeName value:[UIColor orangeColor] range:NSMakeRange(0, 4)];
[menuTextArray addObject:yourString];
次に設定します attributedText
cell.textLabel.attributedText = [menuTextArray objectAtIndex:indexPath.row];
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加