设置UIButton中titleLabel和ImageView的位置
来源:互联网 发布:程序员新员工自我介绍 编辑:程序博客网 时间:2024/04/28 17:02
最近做的项目中遇到怎么设置UIButton里面的titleLable和ImageView的问题,和大家分享下
<span style="font-family:SimSun;font-size:14px;">self.titleButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;</span>
//contentHorizontalAlignment按钮中titleLabel的水平方向的布局
//UIControlContentHorizontalAlignmentCenter 水平居中
//UIControlContentHorizontalAlignmentLeft 左对齐
//UIControlContentHorizontalAlignmentRight 右对齐
//UIControlContentHorizontalAlignmentFill 自适应
<span style="font-family:FangSong_GB2312;"><span style="font-size:14px;">self.titleButton.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;</span></span>
//contentVerticalAlignment 按钮中titleLabel的垂直方向的布局
//UIControlContentVerticalAlignmentCenter 水平居中
//UIControlContentVerticalAlignmentLeft 左对齐
//UIControlContentVerticalAlignmentRight 右对齐
//UIControlContentVerticalAlignmentFill 自适应
<span style="font-family:FangSong_GB2312;font-size:14px;">[self.titleButton setTitleEdgeInsets:UIEdgeInsetsMake(0, 0, 0,0)]; //设置titleLabel的偏移量</span>
<span style="font-family:FangSong_GB2312;font-size:14px;"></span><pre name="code" class="objc"><span style="font-family: FangSong_GB2312;">[self.titleButton setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0,0)]; //设置imageView的偏移量</span>
UIEdgeInsetsMake(top,left,bottom,right);
top:表示向下移多少单位
left:表示向右移多少单位
bottom:表示向上移多少单位
right:表示向左移多少单位
用上面的方法可以更精确的调整titleLabel和imageView的位置
注:仅仅是个人意见,不喜勿喷!
0 0
- 设置UIButton中titleLabel和ImageView的位置
- UIButton中imageView和titleLabel的位置调整
- UIButton中imageView和titleLabel的位置调整
- iOS UIButton的titleLabel和imageView的位置调整
- 编辑UIButton的titleLabel和imageView的位置
- 调整UIButton中的imageView和titleLabel的相对位置
- 格而知之1:UIButton中imageView和titleLabel的位置调整
- 简单修改下UIButton中TitleLabel 和 ImageView 的布局
- Xib中调整button的imageView和TitleLabel的位置
- UIButton如何正确调整imageView及titleLabel的位置
- UIButton如何正确调整imageView及titleLabel的位置
- UIButton如何正确调整imageView及titleLabel的位置
- iOS UIButton如何正确调整imageView及titleLabel的位置
- iOS设置UIButton的titleLabel和imageView需要注意的一些小问题
- UIButton.titleLabel.text和[UIButton setTitle:],UIButton.imageView.image和[UIButton setImage]的区别
- iOS开发技巧:布局UIButton的imageView和titleLabel属性
- iOS开发技巧:布局UIButton的imageView和titleLabel属性
- UIButton 上设置 self.imageView self.titleLabel
- mongoVUE的增删改查操作使用说明
- C中extern的用法
- [主席树 启发式合并] BZOJ 3123 [Sdoi2013]森林
- 使用sys用户删除其他schema下的dblink
- Yandex.Algorithm 2011 Round 2-D - Powerful array-莫队算法(分块算法)
- 设置UIButton中titleLabel和ImageView的位置
- CPLD与FPGA
- SKU
- Android内核开发:如何统计系统的启动时间
- 类型基础
- 让你明白response.sendRedirect()与request.getRequestDispatcher().forward()区别
- 设计模式之装饰模式
- 数据库SQL优化大总结之 百万级数据库优化方案
- python里面的高级特性