使用storyboard设置UIButton的圆角
来源:互联网 发布:ios 软件开发 windows 编辑:程序博客网 时间:2024/06/05 08:06
1. 操作方法:
原理: 通过storyboard的 运行时属性runtime attribute,可以对Button设置圆角或者边框
1.很多人都知道,通常设置一个 Button后者其他的UIView子类的圆角,需要使用如下的语句
<span style="font-size:18px;">self.button.layer.cornerRadius=10;//即可</span><span style="font-size:18px;">说明:这会用到layer图层的属性来实现,原因是在一个 UIView子类中</span>UIView本身只是用来监听事件,而真正显示内容的是layer图层,这当然也包含动画的实现,比如我们对一个view做动画
实际上也是对layer做的动画;
2.但是,总有一些有好奇心的人想知道如何通过,storyboard/xib 设置 一个button或者UIView的圆角:
通过我的研究,我找到一个很强大的方法,可以设置storybord无法添加的属性,比如圆角,或者边框
这个方法就是runtime Attribute运行时属性,也就是在 运行时你设置的这个属性才会起作用,这样体现了oc语言的动态特性和运行时(runtime)的强大
创建一个button然后,设置好约束(以免Button"消失")
一个Button相关的属性,这个属性,可以是在storyboard上没有的属性,此方法类似于代码的效果,每一个属性都有与之对应的值(对象).
0 0
- 使用storyboard设置UIButton的圆角
- iOS 使用storyboard设置UIButton 和UILabel 的圆角
- storyboard 设置UIbutton border Color
- UIButton设置圆角
- 使用xcode storyboard设置按钮圆角方法
- 使用xcode storyboard设置按钮圆角方法
- 使用xcode storyboard设置按钮圆角方法
- 使用xcode storyboard设置按钮圆角方法
- 使用xcode storyboard设置按钮圆角方法
- 使用xcode storyboard设置按钮圆角方法
- 使用xcode在storyboard里设置按钮圆角的方法
- storyboard设置圆角按钮
- 使用storyboard设置label的自适应高度
- UIView/UIButton 设置圆角
- UIButton圆角的设置以及一些系统自定义button
- UIButton的title设置
- UIButton的title设置
- UIButton的一些设置
- contos 64位系统安装32位源码工具
- 模拟+BFS-BZOJ-1611-[Usaco2008 Feb]Meteor Shower流星雨
- JS通过JSONP跨域请求API接口
- linux 下 开启 MySQL的binlog
- Unable to add window -- token null is not for an application(创建Dialog出错)
- 使用storyboard设置UIButton的圆角
- POJ 2251 Dungeon Master 比较有趣的三维迷宫bfs搜索路径
- Oracle Memory Management and HugePage (连载二)
- codecademy 代码学习1
- 从零开始学_JavaScript_系列(十一)——dojo(4)(GRID表格进阶:格式化、style、数据获取、多重排序、点击事件)
- 实测linux的sleep问题
- 热身赛-ZZULIOJ-1873-This offer
- ScrollTo,scrollBy,getScrollX()
- 委托和事件的区别