首页 > 代码库 > iOS代码Button Demo

iOS代码Button Demo

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];   

 

UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = CGRectMake(100, 200, 100, 50);
    btn.backgroundColor = [UIColor redColor];
    [btn addTarget:self action:@selector(onBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];

}

 

- (void)onBtnClick:(id)sender{

//你的功能代码

}

iOS代码Button Demo