UIButton
2016-01-18 10:10
453 查看
1.Button的定义
UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
Button有六种类型
enum {
UIButtonTypeCustom = 0, 自定义风格
UIButtonTypeRoundedRect, 圆角矩形
UIButtonTypeDetailDisclosure, 蓝色小箭头按钮,主要做详细说明用
UIButtonTypeInfoLight, 亮色感叹号
UIButtonTypeInfoDark, 暗色感叹号
UIButtonTypeContactAdd, 十字加号按钮
} UIButtonType;
2.设置尺寸
btn.frame = CGRectMake(0, 0, 100, 100);
[btn setFrame:CGRectMake(0,0,100,100)];
3.设置背景
button1.backgroundColor = [UIColor clearColor];
[button setBackgroundColor:[UIColor blueColor]];
4.state状态
enum {
UIControlStateNormal = 0, 常规状态显现
UIControlStateHighlighted = 1 << 0, 高亮状态显现
UIControlStateDisabled = 1 << 1, 禁用的状态才会显现
};
[btn setTitle:@"cancel" forState:UIControlStateNormal];
5.设置button填充图片和背景图片
[btn setImage:[UIImageimageNamed:@"aaa"]forState:UIControlStateNormal];
[btn setBackgroundImage:[UIImageimageNamed:@"aaa"]forState:UIControlStateNormal];
6.添加或删除事件处理
[btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
[btn removeTarget:nil action:nil forControlEvents:UIControlEventTouchUpInside];
7.按钮是否可以响应
btn.enabled = NO;
UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
Button有六种类型
enum {
UIButtonTypeCustom = 0, 自定义风格
UIButtonTypeRoundedRect, 圆角矩形
UIButtonTypeDetailDisclosure, 蓝色小箭头按钮,主要做详细说明用
UIButtonTypeInfoLight, 亮色感叹号
UIButtonTypeInfoDark, 暗色感叹号
UIButtonTypeContactAdd, 十字加号按钮
} UIButtonType;
2.设置尺寸
btn.frame = CGRectMake(0, 0, 100, 100);
[btn setFrame:CGRectMake(0,0,100,100)];
3.设置背景
button1.backgroundColor = [UIColor clearColor];
[button setBackgroundColor:[UIColor blueColor]];
4.state状态
enum {
UIControlStateNormal = 0, 常规状态显现
UIControlStateHighlighted = 1 << 0, 高亮状态显现
UIControlStateDisabled = 1 << 1, 禁用的状态才会显现
};
[btn setTitle:@"cancel" forState:UIControlStateNormal];
5.设置button填充图片和背景图片
[btn setImage:[UIImageimageNamed:@"aaa"]forState:UIControlStateNormal];
[btn setBackgroundImage:[UIImageimageNamed:@"aaa"]forState:UIControlStateNormal];
6.添加或删除事件处理
[btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
[btn removeTarget:nil action:nil forControlEvents:UIControlEventTouchUpInside];
7.按钮是否可以响应
btn.enabled = NO;
相关文章推荐
- mysql_query()与mysql_real_query()
- UIImageView添加阴影和边框
- building workspace 0%问题未解决
- flex URLLoader和URLRequest浅析
- Java学习笔记(38)-----------Query集合
- java_easyui体系之DataGrid(1)[转]
- java_easyui体系之目录 [转]
- bzoj1570: [JSOI2008]Blue Mary的旅行
- This android SDk requires Android developer......
- UIView缩放动画
- Android UI 基础之ViewPager的使用
- UIResponder简要
- 关于UICollectionViewController的header和foot视图
- getJdbcTemplate().query的使用
- Java之学习笔记(12)-----------数据类型转换valueOf、subString、indexOf用法
- iOS开发中UITableView和UITableViewCell的几种样式
- Leetcode: Range Sum Query 2D - Mutable && Summary: Binary Indexed Tree
- 以金山界面库(openkui)为例思考和分析界面库的设计和实现——代码结构(完)
- 跟我学习dubbo-消息中间件在分布式系统中的作用介绍(8)
- Android UI总结(一) AutoCompleteTextView 组件及一些较为常见的组件