Swift学习之UIButton
来源:互联网 发布:centos yum 安装vim 编辑:程序博客网 时间:2024/05/16 16:18
class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. // 自定义 button var button = UIButton(frame: CGRectMake(self.view.frame.width/2, self.view.frame.height/2, 100, 100)) // 设置按钮标题 button.setTitle("custom", forState: UIControlState.Normal) // 设置按钮标题颜色 button.setTitleColor(UIColor.redColor(), forState: UIControlState.Normal) // 设置按钮标题阴影 button.setTitleShadowColor(UIColor.blackColor(), forState: UIControlState.Normal) // 设置按钮阴影 button.titleLabel?.shadowOffset = CGSizeMake(1.0, 1.0) // 设置按钮标题字体样式 button.titleLabel!.font = UIFont.systemFontOfSize(18) // 设置按钮标题换行模式 button.titleLabel!.lineBreakMode = .ByTruncatingTail // 设置按钮背景色 button.backgroundColor = UIColor(red:0.8,green:0.8,blue:0.8,alpha:1.0) // 设置按钮内部内容边距 button.contentEdgeInsets = UIEdgeInsetsMake(-20, 0, 0, 0) // 去掉高亮状态下的图像颜色加深 button.adjustsImageWhenHighlighted = false; // 去掉禁用状态下的图像颜色加深 button.adjustsImageWhenDisabled = false; // 添加按钮按下发光效果 button.showsTouchWhenHighlighted = true; // 添加点击事件 button.addTarget(self,action:"buttonClicked:",forControlEvents:UIControlEvents.TouchUpInside) // 设置按钮标签 button.tag = 1 } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } func buttonClicked(sender: UIButton!){ println(sender.tag) } }
0 0
- Swift学习之UIButton
- Swift学习之UIButton
- swift之UIButton
- Swift基础之UIButton
- Swift UI学习之基础:UIButton,UILabel and UISlider
- Swift UI学习之基础:UIButton,UILabel and UISlider
- Swift UI学习之基础:UIButton,UILabel and UISlider
- Swift之贪婪的UIButton
- Swift之贪婪的UIButton
- Swift之贪婪的UIButton
- swift控件之旅之UIButton
- OC学习之UIButton
- IOS学习之UIButton
- IOS学习之UIButton
- Swift学习第六枪-UIButton和UILable
- [赵三哥Swift学习笔记]UIButton
- swift代码创建控件之UIButton
- 【swift系列之UIButton】简单使用
- 调试fpm的一些小笔记
- 项目升级感悟(验证码图片src后面加随机数)
- http请求
- CSS3特殊属性整理
- 书签
- Swift学习之UIButton
- maven'
- lightoj 1080 Binary Simulation (线段树区间更新)
- 解密Apache HAWQ ——功能强大的SQL-on-Hadoop引擎 [作者:常雷]
- 读书笔记--IPC机制(一)
- Android——自定义通知栏使用
- 使用Enterprise Architect 设计数据库
- Python基础——@staticmethod与@classmethod
- JS判断是否是微信页面,判断手机操作系统(ios或android)并跳转到不同下载页面