#pragma mark - 创建一个UIButton对象
UIButton *button = [UIButton buttonWithType:(UIButtonTypeSystem)];
button.frame = CGRectMake(100, 100, 100, 100);
button.backgroundColor = [UIColor redColor];
[self.view addSubview:button];
#pragma mark - 添加事件
[button addTarget:self action:@selector(ButtonClick) forControlEvents:(UIControlEventTouchUpInside)];
#pragma mark - 移除事件
//[button removeTarget:self action:@selector(ButtonClick) forControlEvents:(UIControlEventTouchUpInside)];
#pragma mark - 外观控制
//设置指定状态下的标题
//[button setTitle:@"点击" forState:(UIControlStateNormal)];
//获取指定状态下的标题
NSString *str = [button titleForState:(UIControlStateNormal)];
//设置指定状态下的标题颜色
[button setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
//获取指定状态下得标题颜色
UIColor *color = [button titleColorForState:(UIControlStateNormal)];
//设置指定状态下得标题阴影颜色
[button setTitleShadowColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
//获取指定状态下得标题阴影颜色
UIColor *shadowColor = [button titleShadowColorForState:(UIControlStateNormal)];
//设置指定状态下得前景图片
[button setImage:[UIImage imageNamed:@"1.png"] forState:(UIControlStateNormal)];
//获取指定状态下的前景图片
UIImage *image = [button imageForState:(UIControlStateNormal)];
//设置指定状态下的背景图片
[button setBackgroundImage:[UIImage imageNamed:@"1.png"] forState:(UIControlStateNormal)];
//获取指定状态下得背景图片
UIImage *bgImage = [button backgroundImageForState:(UIControlStateNormal)];