os 新建button并为button添加事件

 

NSButton *button=[[NSButton alloc]initWithFrame:CGRectMake(80, 200, 200, 80)];
    [button setTitle:@"aa"];
   [button setAction:@selector(b)];
    NSRect window_frame=[self.window frame];
    NSView *view=[[NSView alloc]initWithFrame:window_frame];
    [view addSubview:button];
    [self.window setContentView:view];

你可能感兴趣的:(OS)