UIButton图片文字上下布局
作者:
王兆龙 | 来源:发表于
2017-03-22 09:21 被阅读0次//使图片和文字水平居中显示
btn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
//文字距离上边框的距离增加imageView的高度,距离左边框减少imageView的宽度,距离下边框和右边框距离不变
[btn setTitleEdgeInsets:UIEdgeInsetsMake(btn.imageView.frame.size.height + 5 ,-btn.imageView.frame.size.width, 0.0,0.0)];
//图片距离右边框距离减少图片的宽度,其它不边
[btn setImageEdgeInsets:UIEdgeInsetsMake(-15, 0.0,0.0, -btn.titleLabel.bounds.size.width)];
本文标题:UIButton图片文字上下布局
本文链接:https://www.haomeiwen.com/subject/xpnnnttx.html
网友评论