macOS/iOS API解説

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

目次

setButtonType:

INDEX>AppKit>NSButton

ボタンタイプをセットします

Objective-C

- (void)setButtonType:(NSButtonType)aType

Swift

func setButtonType(_ aType: NSButtonType)

解説

ボタンタイプをセットします。
f:id:jjj777:20150225222449p:plain

f:id:jjj777:20150225222517p:plain

【NSButtontype】
● NSMomentaryLight
● NSMomentaryPushButton
● NSMomentaryChangeButton
● NSPushOnPushOffButton on/offボタン
● NSOnOffButton
● NSToggleButton
● NSSwitchButton チェックボックス
● NSRadioButton ラジオボタン

返り値

なし

引数

Objective-C

(NSButtonType)aType

Swift

_ aType: NSButtonType

ボタンタイプの定数

フレームワーク

ApplicationKit

クラス

NSButton

使用可能

10.0-

関連記事(外部サイト)

例文

Objective-C

#import "MyObject.h"

@implementation MyObject

- (IBAction)myAction:(id)sender
{
	//senderはボタン
	[sender setButtonType : NSToggleButton ];
}

@end

Swift

//NSButton setButtonType
    //Swift2.0
    @IBAction func function001(sender: AnyObject) {
        myButton.setButtonType(NSButtonType.PushOnPushOffButton)
        // MomentaryLightButton // was NSMomentaryPushButton
        // PushOnPushOffButton
        // ToggleButton
        // SwitchButton
        // RadioButton
        // MomentaryChangeButton
        // OnOffButton
        // MomentaryPushInButton // was NSMomentaryLight
    }

更新時のバージョン

OS X 10.10