addTemporaryAttributes:forCharacterRange:
一時的な文字属性を追加します
-(void)addTemporaryAttributes:(NSDictionary *)attrs: forCharacterRange:(NSRange)charRange:
解説
一時的な文字属性を追加します。画面表示だけに使います。スペルチェックで間違っている語に下線を引いたりします。下線とカラーのみ使えます。
【attrsの要素】文字属性名の辞書の要素
● NSForegroundColorAttributeName 描画カラー
● NSUnderlineStyleAttributeName 下線
返り値
( void )
なし
引数
( NSDictionary * )attrs
属性の辞書
( NSRange )charRange
範囲
フレームワーク
ApplicationKit
クラス
NSLayoutManager
Instance Methods
使用可能
10.0
参照
例文
#import "MyObject.h" @implementation MyObject - (IBAction)myAction:(id)sender { //myOutletはTextView NSLayoutManager *layM; NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys: [NSColor redColor],NSForegroundColorAttributeName, nil]; layM = [myOutlet layoutManager]; NSLog([[layM firstTextView] className]); [[layM firstTextView] insertText:@"the red text"]; [layM addTemporaryAttributes:dic forCharacterRange:NSMakeRange(4,3) ]; } @end