macOS/iOS API解説

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

目次

setAttributedTitle:

ボタンに属性付文字列をセットして再描画します
-(void)setAttributedTitle:(NSAttributedString *)aString:

解説

ボタンに属性付文字列をセットして再描画します。

返り値

( void )

なし

引数

( NSAttributedString * )aString

セットする属性付タイトル

フレームワーク

ApplicationKit

クラス

NSButton

Instance Methods

使用可能

10.0

参照

- setAttributedAlternateTitle:
- setButtonType:
- setFont:(NSButtonCell)

例文

#import "MyObject.h"

@implementation MyObject

- (IBAction)myAction:(id)sender
{
	//属性付き文字列作成
	NSAttributedString *attStr = [[[NSMutableAttributedString alloc] initWithString:@"Bold Title" attributes:[self systemBoldFontAttributes]] autorelease];
	
	//ボタンmyOutLetに代理タイトルセット
	[myOutlet setAttributedTitle:attStr];
	
}

//太字のシステムフォント属性を返す。
- (NSDictionary*)systemBoldFontAttributes {
    return [NSDictionary dictionaryWithObject: [NSFont boldSystemFontOfSize:[NSFont systemFontSize]] forKey:NSFontAttributeName];
}
@end