Button(按钮)
总结:
/**
1. 按钮的风格:
1)UIButtonTypeCustom-------用于自定义按钮
2)UIButtonTypeRoundedRect-----白色圆角矩形
3)UIButtonTypeDetailDisclosure---一种蓝色样式按钮
4)UIButtonTypeInfoDark-------深色背景信息按钮
5)UIButtonTypeInfoLight--------浅色背景信息按钮
6)UIButtonTypeContactAdd------蓝色加号按钮
2.设置样式
1)设置标题-----调用函数setTitle:(title) forState:(控件状态)
2)设置标题颜色------btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
3)设置背景图片-----[btn setBackgroundImage:newIUmage forState:UIControlStateNormal];
4)设置背景颜色------- btn.backgroundColor = [UIColor clearColor];
3.添加响应
[btn addTarget:self action:@selector(Action:) forControlEvents:UIControlEventTouchUpInside];
*/
举例:
//1.初始化
//a)普通方法
UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(10, 10, 80, 44)];
//b)类方法
UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeContactAdd];
//设置title
[btn setTitle:@"title" forState:UIButtonTypeCustom];
//设置TitleColor
[btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
//设置背景图片
[btn setBackgroundImage:newIUmage forState:UIControlStateNormal];
//设置背景颜色
btn.backgroundColor = [UIColor clearColor];
//添加btn的响应时间
[btn addTarget:self action:@selector(Action:) forControlEvents:UIControlEventTouchUpInside];
版权声明:本文为qq_31151129原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。