-(void)viewDidLoad{
//初始化
self.btn1 = [UIBotton buttonWithType:UIButtonTypeRoundedRect];
//设置大小
self.btn1.frame = CGRectMake(20,20,100,50);
//设置标题
[self.btn1 setTitle:@"Hello" forState:UIControlStateNormal];
//添加点击事件
[self.btn1 addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
//呈现控件
[self.view addSubView:self.btn1];
}
//按钮的点击事件
-(IBAction) click:(id)sender
{
UIButton * button = (UIButton*)sender;
NSString *title = btn.titleLabel.text;
NSLog(@"%@",title);
}