1.定义一个按钮
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];//圆角矩形
2.设置按钮大小
button.frame = CGRectMake(100, 100, 100, 100);
[button setFrame:CGRectMake(100, 100, 100, 100)];
3.设置普通状态下的按钮
[button setTitle:@"姓名" forState:UIControlStateNormal];//文字
[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];//字体颜色
[button setBackgroundImage:[UIImage imageNamed:@"Unlock_DotLock1_Selected"] forState:UIControlStateNormal];//背景图片
4.设置点击时候的按钮
[button setTitle:@"王凯瑜" forState:UIControlStateHighlighted];
[button setTitleColor:[UIColor redColor] forState:UIControlStateHighlighted];
[button setBackgroundImage:[UIImage imageNamed:@"Unlock_DotLock_Wrong1" ] forState:UIControlStateHighlighted];
5.添加到视图中
[self.view addSubview:button];
6.设置按钮能不能与用户交互
button.enabled = NO;
[button setTitle:@"英雄联盟" forState:UIControlStateDisabled];