1月18号 UIButton

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];

 

 

posted @ 2016-01-18 13:36  南城半夏北风过丶  阅读(100)  评论(0编辑  收藏  举报