ios之按钮创建

来源:互联网 发布:现在学php有前途吗 编辑:程序博客网 时间:2024/05/19 06:18

1、CGRect aRect= CGRectMake(START_X, START_Y, WIDTH, HEIGHT);

   UIButton *myButton = [UIButton all0c] initWithFrame:aRect]; 

  [myButton addTarget:self action: @selector(method:) forControlEvents: UIControlEventTouchUpside];


2、在Interface Builder中,你可以通过从界面对象组件面板中将按钮拖到应用程序主窗口中来完成。