UIButton 设置image ,title和setBackgroundImage
来源:互联网 发布:linux 禁止删除文件夹 编辑:程序博客网 时间:2024/06/05 20:37
定制一个image 和title 有一定距离的UIButton
// the space between the image and textCGFloat spacing = 6.0;// lower the text and push it left so it appears centered // below the imageCGSize imageSize = button.imageView.image.size;button.titleEdgeInsets = UIEdgeInsetsMake( 0.0, - imageSize.width, - (imageSize.height + spacing), 0.0);// raise the image and push it right so it appears centered// above the textCGSize titleSize = [button.titleLabel.text sizeWithAttributes:@{NSFontAttributeName: button.titleLabel.font}];button.imageEdgeInsets = UIEdgeInsetsMake( - (titleSize.height + spacing), 0.0, 0.0, - titleSize.width);
UIButton的setBackgroundImage
是设置背景图片,而setImage
则是设置一个挨着title的一个icon 或者image。
就是如果你设置的是backgroundImage 而不是image的话,那么如果这个图片过小的话这个图片是会被拉伸的。
0 0
- UIButton 设置image ,title和setBackgroundImage
- UIButton 的 image 和title 位置设置
- iOS UIButton同时设置title和image属性
- UIButton通过UIEdgeInsetsMake设置image和title的位置
- iOS UIButton同时设置title和image属性
- UIButton 设置 image 和 title 的布局问题
- 使用UIButton设置title和image,达到tabBarItem的效果
- 设置UIButton的image title 位置
- UIButton设置title在下,image在上
- 给UIButton添加title和image
- 自定义UIButton的title和image位置
- UIButton的Image和Title的布局
- UIButton 调整title和image的位置
- UIButton的Image和Title的布局
- 设置UIButton的Title在左,Image在右
- UIButton 关于 setBackgroundImage 和 setImage的区别
- UIButton之 setBackgroundImage 和 setImage区别
- 关于UIButton的 setBackgroundImage 和 setImage区别
- 第4章 手机平板要兼顾,探究碎片
- Objective-C RunTime那些事儿
- AJAX
- java基础知识汇总
- 第5章 全局大喇叭,详解广播机制
- UIButton 设置image ,title和setBackgroundImage
- 第6章 数据存储全方案
- 修改CentOS 7网卡名称eno16777736为eth0
- HTML5 使用浏览器内置数据库之 indexedDB
- 第7章 跨程序共享数据,探究
- AndroidManifest.xml文件解析
- leetcode之Maximum Gap
- swift 学习笔记 --> Array
- css定义select样式