iOS UIButton如何正确调整imageView及titleLabel的位置
来源:互联网 发布:java线程应用场景 编辑:程序博客网 时间:2024/04/28 11:36
一些开发者知道通过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,便于得到正确的以设备点为单位的宽度及高度
- iOS UIButton如何正确调整imageView及titleLabel的位置
- UIButton如何正确调整imageView及titleLabel的位置
- UIButton如何正确调整imageView及titleLabel的位置
- 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的位置
- iOS开发技巧:布局UIButton的imageView和titleLabel属性
- iOS开发技巧:布局UIButton的imageView和titleLabel属性
- UIButton的ImageView与TitleLabel对齐
- iOS设置UIButton的titleLabel和imageView需要注意的一些小问题
- ios 关于如何调整cell.imageView中的ImageView大小及位置
- 剑指 offer:调整数组顺序使奇数位于偶数前面
- 数据存储--SharedPreferences--仿QQ登陆界面记住密码效果
- 小技巧,使用低版本的VS打开高版本的解决方案(使用VS2008打开VS2010的解决方案--同样适用于其他版本)
- 比较好的博客链接
- 关于flash播放器不为人知的四大点
- iOS UIButton如何正确调整imageView及titleLabel的位置
- wincc VBS脚本解密
- linux服务器远程桌面配置-X2Go 方式
- Java整数转换成字符
- 关于activity继承的抽象类Context(基类)
- centos文件查找
- 2015网易游戏笔试题01
- [python] 0x2 Python Tutorial: Reverse Shell
- 硬件知识andl linux发展历史