setAlignment:range:
属性付き文字列の配置をセットします
-(void)setAlignment:(NSTextAlignment)alignment: range:(NSRange)aRange:
解説
属性付き文字列の配置をセットします。
aRangeがレシーバの範囲を越えればNSRangeExceptionを起こします。
【NSTextAlignment】
● NSLeftTextAlignment 左揃え
● NSRightTextAlignment 右揃え
● NSCenterTextAlignment センター揃え
● NSJustifiedTextAlignment ジャスティファイ
● NSNaturalTextAlignment 自動(初期設定)
NSNaturalTextAlignmentは文字の言語の自然な配置として、他の配置のうちの1つを使って表示されます。
返り値
( void )
なし
引数
( NSTextAlignment )alignment
文字配置
( NSRange )aRange
範囲
フレームワーク
ApplicationKit
クラス
NSMutableAttributedString Additions
Instance Methods
使用可能
10.0
参照
- applyFontTraits:range:
- fixParagraphStyleAttributeInRange:
例文
#import "MyObject.h" @implementation MyObject - (IBAction)myAction:(id)sender { NSMutableAttributedString *maStr =[[[NSMutableAttributedString alloc] initWithString:@"AttributedString" attributes:nil] autorelease]; //スタイル指定 [maStr setAlignment:NSRightTextAlignment range:NSMakeRange(0,[maStr length])]; [myOutlet setAttributedStringValue:maStr]; } @end