UIButton文字在左图片在右、空心带边框
来源:互联网 发布:淘宝口碑网 编辑:程序博客网 时间:2024/04/29 22:55
- (void)setImageOnRightWithImage:(UIImage *)image forState:(UIControlState)state{ [self setImage:image forState:state]; NSAttributedString *title = [[self titleForState:state] length] > 0 ? [[NSAttributedString alloc] initWithString:[self titleForState:state]] : [self attributedTitleForState:state]; CGSize textSize = title.size; [self setImageEdgeInsets:UIEdgeInsetsMake(0, textSize.width, 0, -textSize.width)]; [self setTitleEdgeInsets:UIEdgeInsetsMake(0, -image.size.width, 0, image.size.width)]; [self setContentEdgeInsets:UIEdgeInsetsMake(10, 10, 10, 10)];}
在使用这个方法前,需要设置btn的title或者attributedTitle,尽量使用attributedTitle;
调整完image和title的edgeInsets后,btn本省的edgeInsets会被置成zero,需重新设置新的edgeInsets
1 0
- UIButton文字在左图片在右、空心带边框
- UIButton 设置圆角 边框颜色 点击回调方法 &&图片在右文字在左
- UIButton浅析,图片在右,文字在左
- UIButton的图片在右文字在左
- UIButton左文字右图片
- UIButton 文字在左,icon在右的办法
- UIButton实现左文字右图片
- uibutton实现左文字右图片
- UIButton实现左文字右图片
- UIButton实现左文字右图片
- UIButton左文字右图片,上图片下文字
- UIButton文字居左,图片居右~Xib
- 设置按钮中 图片&文字的位置,文字在左 图片在右
- 设置UIButton的Title在左,Image在右
- Swift里自定义一个文字在左、图片在右的,标题按钮
- 导航栏添加自定义按钮(图片在左文字在右)
- 在左在右
- 在Button上、下、左、右位置添加图片和文字
- 辅助存储管理-组织数据
- 创建一个popwindow 并动态设置pop的高度 限定pop高度
- 冒泡、归并、快速、桶、堆排序
- 时钟的制作
- vim的c语言环境简单配置
- UIButton文字在左图片在右、空心带边框
- NodeJs杂记
- 关于系统性能调优的一点思考
- iReport传入参数使用说明
- 莫干山祼心谷越野体验
- 设计模式之单例模式 (模板 智能指针 删除器) 实现【饿汉】
- myeclipse中导入的jquery文件报错(出现红叉叉,提示语法错误)
- Android中的跨进程通信的实现(一)——远程调用过程和aidl
- uva11090Going in Cycle!!【bellman二分判负环】