Swift UIButton UIButtonType
来源:互联网 发布:腾讯数据库有多大 编辑:程序博客网 时间:2024/05/20 01:47
UIButton 有一个枚举
UIButtonType
专门用来指定button的类型
这里我们尝试一下接种类型看看效果、
//按钮的几种类型 //系统默认button let btn1=UIButton.buttonWithType(UIButtonType.System) as! UIButton btn1.frame=CGRectMake(20, 50, 320, 36); btn1.setTitle("SystemButton", forState: UIControlState.Normal); self.view.addSubview(btn1); //所有属性需要自定义,否则字体颜色为白色 let btn2=UIButton.buttonWithType(UIButtonType.Custom) as! UIButton btn2.frame=CGRectMake(20, 100, 320, 36); btn2.setTitle("CustomButton", forState: UIControlState.Normal); btn2 .setTitleColor(UIColor.blackColor(), forState: UIControlState.Normal) self.view.addSubview(btn2); //以下为几种带图标的button let btn3=UIButton.buttonWithType(UIButtonType.DetailDisclosure) as! UIButton btn3.frame=CGRectMake(20, 150, 320, 36); btn3.setTitle("DetailDisclosureButton", forState: UIControlState.Normal); self.view.addSubview(btn3); let btn4=UIButton.buttonWithType(UIButtonType.InfoLight) as! UIButton btn4.frame=CGRectMake(20, 200, 320, 36); btn4.setTitle("InfoLightButton", forState: UIControlState.Normal); self.view.addSubview(btn4); let btn5=UIButton.buttonWithType(UIButtonType.InfoDark) as! UIButton btn5.frame=CGRectMake(20, 250, 320, 36); btn5.setTitle("InfoDarkButton", forState: UIControlState.Normal); self.view.addSubview(btn5); let btn6=UIButton.buttonWithType(UIButtonType.ContactAdd) as! UIButton btn6.frame=CGRectMake(20, 300, 320, 36); btn6.setTitle("ContactAddButton", forState: UIControlState.Normal); self.view.addSubview(btn6);
需要注意的是 按照以上几种方式创建的button将不能相互转换为其他类型了
苹果开发群 :414319235 欢迎加入 欢迎讨论问题
0 0
- Swift UIButton UIButtonType
- swift UIButton
- Swift UIButton
- swift uibutton
- UIButton swift
- swift UIButton
- swift UIButton
- swift UIButton使用
- swift UIButton的使用
- swift UIButton的使用
- Swift创建UIButton
- swift之UIButton
- Swift-UIButton&AlertView
- Swift 创建UIButton
- Swift学习之UIButton
- Swift学习之UIButton
- Swift 按钮(UIButton)
- Swift--UI--UIButton
- 解决android:background背景图片被拉伸问题
- [leetcode][Binary Search] H-Index II
- android学习笔记(17)广播事件处理进阶(注册方法)
- IOS中宏定义
- java 解决中文乱码
- Swift UIButton UIButtonType
- android 制作9.png图片
- Go环境搭建
- MSSQL数据库测试连接的快捷方法
- Java获取时间范围: 当前季度,上个季度,昨天,当前月,上个月
- Codeforces 567E President and Roads (用Dijkstra求最短路条数 + 强连通桥)
- HDU 5428 The Factor
- 好好学语文
- Linux字符设备驱动之Tiny6410 LED驱动分析