UIButton如何正确调整imageView及titleLabel的位置
来源:互联网 发布:常德第七元素网络 编辑:程序博客网 时间:2024/05/16 19:46
一些开发者知道通过imageEdgeInsets及titleEdgeInsets可以调整imageView及titleLabel的位置,但不知道如何正确计算,基本上都是通过多次调整相应的值达到期望的目标(次数过多可能会失去信心),究其原因就是不能正确理解imageEdgeInsets及titleEdgeInsets.
下面步入主题.
如果button的bounds足够大(宽度至少是imageView宽度与titleLabel宽度之和,高度至少为imageView高度与titleLabel高度中的最大值),那么就可以同时显示imageView及titleLabel,如下图:
如果,想要得到imageView及titleLabel都居中显示,且要达到imageView在上,titleLabel在下的效果(通过设置imageView及titleLabel的frame是无法达到这样的效果的),如下图:
此时,button的bounds也要足够大(宽度至少是imageView宽度与titleLabel宽度之和,高度至少为imageView高度与titleLabel高度之和),并且,需要修改button的imageEdgeInsets及titleEdgeInsets.可参考下面的代码:
//这里的图片,必须有Xcode.png及Xcode@2x.png,便于得到正确的以设备点为单位的宽度及高度
- UIButton如何正确调整imageView及titleLabel的位置
- UIButton如何正确调整imageView及titleLabel的位置
- UIButton如何正确调整imageView及titleLabel的位置
- iOS UIButton如何正确调整imageView及titleLabel的位置
- UIButton,送给多数开发者的释疑文章,关于如何正确调整imageView及titleLabel的位置
- iOS UIButton的titleLabel和imageView的位置调整
- UIButton中imageView和titleLabel的位置调整
- UIButton中imageView和titleLabel的位置调整
- 调整UIButton中的imageView和titleLabel的相对位置
- 格而知之1:UIButton中imageView和titleLabel的位置调整
- 编辑UIButton的titleLabel和imageView的位置
- 设置UIButton中titleLabel和ImageView的位置
- Xib中调整button的imageView和TitleLabel的位置
- UIButton的ImageView与TitleLabel对齐
- 如何调整UIButton里面的文字位置
- UIButton.titleLabel.text和[UIButton setTitle:],UIButton.imageView.image和[UIButton setImage]的区别
- iOS开发技巧:布局UIButton的imageView和titleLabel属性
- iOS开发技巧:布局UIButton的imageView和titleLabel属性
- hdu 5007 Post Robot
- SPServices介绍之四:实现查阅项的级联选择功能(联动功能)
- 使用eclipse调试python出现SyntaxError:Non-UTF-8 code解决办法
- js window 对象
- SpringMVC学习系列(4) 之 数据绑定-1
- UIButton如何正确调整imageView及titleLabel的位置
- 香港有限公司税务申报要求及程序是什么?
- Html5笔记
- YoxView - jQuery图片浏览特效
- SPServices介绍之五:调用Workflow
- ubuntu14问题
- 递归函数时间复杂度分析
- 在JSP页面获取当前项目名称的方法
- SPServices介绍之六:上传附件