ios 初体验<UIButton 控件>
1.创建UIButton 跟其他方式不同,不是直接alloc,init 创建 用工厂化方式创建
UIButton *sureBtn = [UIButton buttonWithType:UIButtonTypeSystem];//选择Button 的样式 系统给定的
//按钮的位置
sureBtn.frame = CGRectMake(60, 600, 300, 30);
//设在按钮背景颜色
sureBtn.backgroundColor = [UIColor blueColor];
//设置按钮正常状态的文字
[sureBtn setTitle:@"点击了" forState:UIControlStateNormal];
//设置正常状态的颜色
[sureBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
//按钮选中状态
[sureBtn setTitle:@"被点击了" forState:UIControlStateSelected];
[sureBtn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
// 设置圆角的半径
sureBtn.layer.cornerRadius = 10;
sureBtn.clipsToBounds = YES;
// 按钮所要做的事件
[sureBtn addTarget:self action:@selector(sureButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
//添加到视图控制区
[self.view addSubview:sureBtn];
最新文章
- ASP.NET MVC3中Controller与View之间的数据传递
- leetcode52. N-Queens II
- 第一个Object-C类
- JAVA定时执行任务,每天定时几点钟执行任务
- JS闭包的两个使用方向
- spring计划任务,springMvc计划任务,Spring@Scheduled,spring定时任务
- php 获取客户端IP地址
- Mounting File Systems
- VS2010安装项目的系统必备中添加.NET 2.0
- 台式电脑部署xen虚拟化的各种问题
- Android 界面滑动实现---Scroller类 从源码和开发文档中学习(让你的布局动起来)
- MDX的实例讲解(排名前15的小例子)
- auto-encoder小记
- python编码转换
- jumperserver3.0的安装部署
- Lazarus分体式改成一体式窗口
- JavaScript数据结构-8.双向链表
- [USACO12DEC] 逃跑的BarnRunning Away From…(主席树)
- iOS越狱系统使用root权限运行命令
- python:控制鼠标和键盘