在storyBoard连线的时候,方法返回值是IBAction,所谓IBAction就是可以连线的void
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setFrame:CGRectMake(110.0, 220.0, 100.0, 40.0)];
[button setTitle:@"button默认状态" forState:UIControlStateNormal];
[button setTitle:@"button点击状态" forState:UIControlStateHighlighted];
[button setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
[button setTitleColor:[UIColor greenColor] forState:UIControlStateHighlighted];
[button setBackgroundColor:[UIColor orangeColor]];
//点击执行的函数
[button addTarget:self action:@selector(tapButton) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];