macOS/iOS API解説

iOS , Mac アプリケーション開発のために使われる主要フレームワークの日本語情報です。2010年代に書かれた内容です。今後更新はありません。

目次

fixAttributesInRange:

指定した範囲の文字の属性をなくします
-(void)fixAttributesInRange:(NSRange)aRange:

解説

指定した範囲の文字の属性をなくします。
直前の文字の属性が適用されます。
aRangeがレシーバの範囲を越えればNSRangeExceptionを起こします。

返り値

( void )

なし

引数

( NSRange )aRange

範囲

フレームワーク

ApplicationKit

クラス

NSMutableAttributedString Additions

Instance Methods

使用可能

10.0

参照

- fixAttachmentAttributeInRange:
- fixFontAttributeInRange:
- fixParagraphStyleAttributeInRange:

例文

#import "MyObject.h"

@implementation MyObject

- (IBAction)myAction:(id)sender
{
NSMutableAttributedString *maStr =[[[NSMutableAttributedString alloc] initWithString:@"AttributedString" attributes:nil] autorelease];
//スタイル指定
[maStr applyFontTraits:( NSBoldFontMask | NSItalicFontMask )
            range:NSMakeRange(2,5)];
        
[myOutlet setAttributedStringValue:maStr];

}

- (IBAction)fix:(id)sender
{
NSMutableAttributedString *maStr1 =[[[NSMutableAttributedString alloc] initWithString:@"" attributes:nil] autorelease];

[maStr1 appendAttributedString:[myOutlet attributedStringValue]];

[maStr1 fixAttributesInRange:NSMakeRange(1,10)];
[myOutlet setAttributedStringValue:maStr1];
}
@end