setAttributedString:
変更可能な属性付き文字列をセットします
-(void)setAttributedString:(NSAttributedString *)attributedString:
解説
変更可能な属性付き文字列をセットします。
いままでの文字列の全てを置き換えます。
返り値
( void )
なし
引数
( NSAttributedString * )attributedString
属性付き文字列
フレームワーク
Foundation
クラス
NSMutableAttributedString
Instance Methods
使用可能
10.0
参照
- appendAttributedString:
例文
#import "MyObject.h" @implementation MyObject - (IBAction)myAction:(id)sender { NSMutableAttributedString *maStr =[[[NSMutableAttributedString alloc] initWithString:@"AttributedString" attributes:nil] autorelease]; NSMutableAttributedString *maStr2 =[[[NSMutableAttributedString alloc] initWithString:@"repString" attributes:nil] autorelease]; //書体指定 [maStr addAttribute:NSFontAttributeName value:[NSFont fontWithName:@"Osaka" size:15.0] range:NSMakeRange(2,5)]; //描画色指定 [maStr addAttribute:NSForegroundColorAttributeName value:[NSColor redColor] range:NSMakeRange(0, [maStr length])]; [maStr setAttributedString:maStr2]; [myOutlet setAttributedStringValue:maStr]; } - (NSDictionary*)boldFontAttributes { return [NSDictionary dictionaryWithObject: [NSFont boldSystemFontOfSize:[NSFont systemFontSize]] forKey:NSFontAttributeName]; } @end