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

最新文章

  1. ASP.NET MVC3中Controller与View之间的数据传递
  2. leetcode52. N-Queens II
  3. 第一个Object-C类
  4. JAVA定时执行任务,每天定时几点钟执行任务
  5. JS闭包的两个使用方向
  6. spring计划任务,springMvc计划任务,Spring@Scheduled,spring定时任务
  7. php 获取客户端IP地址
  8. Mounting File Systems
  9. VS2010安装项目的系统必备中添加.NET 2.0
  10. 台式电脑部署xen虚拟化的各种问题
  11. Android 界面滑动实现---Scroller类 从源码和开发文档中学习(让你的布局动起来)
  12. MDX的实例讲解(排名前15的小例子)
  13. auto-encoder小记
  14. python编码转换
  15. jumperserver3.0的安装部署
  16. Lazarus分体式改成一体式窗口
  17. JavaScript数据结构-8.双向链表
  18. [USACO12DEC] 逃跑的BarnRunning Away From…(主席树)
  19. iOS越狱系统使用root权限运行命令
  20. python:控制鼠标和键盘

热门文章

  1. MySql 事务与锁
  2. python 分支语句 循环语句
  3. VS2010 常见错误类型汇总
  4. gitlab+jenkins持续集成(一)
  5. java学习笔记随记
  6. Java-将多线程停止的两种方法
  7. MySQL之增_insert-replace
  8. Loadrunner 网页诊断图
  9. java虚拟机详解
  10. U3D操作游戏对象