美文网首页
UIbutton 实现左文字 右图片

UIbutton 实现左文字 右图片

作者: VickyLanLan | 来源:发表于2017-03-14 14:17 被阅读183次

方法一:

CGFloatlabelWidth = [button.titleLabel.textsizeWithFont:button.titleLabel.font].width;

[buttonsetTitleEdgeInsets:UIEdgeInsetsMake(0, -image.size.width,0, image.size.width)];

[buttonsetImageEdgeInsets:UIEdgeInsetsMake(0, labelWidth,0, -labelWidth)];

方法二:

自定义CZTitleButton继承UIbutton,重写layoutSubviews方法(见如下代码):

相关文章

网友评论

      本文标题:UIbutton 实现左文字 右图片

      本文链接:https://www.haomeiwen.com/subject/tzxhnttx.html