addAttributes:range:
変更可能な属性付き文字列に辞書で文字属性を付加します
-(void)addAttributes:(NSDictionary *)attributes: range:(NSRange)aRange:
解説
変更可能な属性付き文字列に辞書で文字属性を付加します。
範囲(aRange)がレシーバの範囲を越えればNSRangeExceptionを返します。
属性辞書(attributes)がnilならNSInvalidArgumentExceptionを返します。
返り値
( void )
なし
引数
( NSDictionary * )attributes
属性の辞書
( NSRange )aRange
範囲
フレームワーク
Foundation
クラス
NSMutableAttributedString
Instance Methods
使用可能
10.0
参照
- addAttribute:value:range:
- removeAttribute:range:
例文
#import "MyObject.h" @implementation MyObject - (IBAction)myAction:(id)sender { NSMutableAttributedString *maStr =[[[NSMutableAttributedString alloc] initWithString:@"AttributedString" attributes:nil] autorelease]; [maStr addAttributes:[self boldFontAttributes] range:NSMakeRange(2,10)]; [myOutlet setAttributedStringValue:maStr]; } - (NSDictionary*)boldFontAttributes { return [NSDictionary dictionaryWithObject: [NSFont boldSystemFontOfSize:[NSFont systemFontSize]] forKey:NSFontAttributeName]; } @end