## NSButton ****初始化,常用属性的设置
NSButton *btn = [[NSButton alloc] initWithFrame:CGRectMake(100, 0, 100, 100)];
/**
*
* 这4中风格基本一样, 点击带蓝色的是1,点击带灰色的是2、3、4
NSRoundedBezelStyle = 1,
NSRegularSquareBezelStyle = 2,
NSThickSquareBezelStyle = 3,
NSThickerSquareBezelStyle = 4,
*/
[btn setBezelStyle:NSThickSquareBezelStyle];
[btn setTitle:@"点击"];
/**
* btn的类型,像, radio, check, 开关按钮都用这个属性设置
*/
[btn setButtonType:NSMomentaryLightButton];
// 设置按钮上文字的对齐方式
// [[btn cell] setAlignment:NSTextAlignmentCenter];
// [[btn cell] setFont:[NSFont systemFontOfSize:30]];
// 一般用法, 用这个就够了, 设置btn的属性,别用cell,坑人
[btn setAlignment:NSTextAlignmentCenter];
[btn setFont:[NSFont systemFontOfSize:30]];
[btn setSound:[NSSound soundNamed:@"Pop"]];
[self.view addSubview:btn];
[btn setTarget:self];
[btn setAction:@selector(handelClick)];
网友评论