美文网首页
调整button为上图片下文字

调整button为上图片下文字

作者: 精神薇 | 来源:发表于2020-04-16 13:19 被阅读0次
///调整按钮为上图片下文字
+ (void)adjustButtonImageViewUPTitleDownWithButton:(UIButton *)button withSpace:(CGFloat)space {
    [button.superview layoutIfNeeded];
    [button setTitleEdgeInsets:UIEdgeInsetsMake(button.imageView.frame.size.height+space ,-button.imageView.frame.size.width, 0.0,0.0)];//文字距离上边框的距离增加imageView的高度,距离左边框减少imageView的宽度,距离下边框和右边框距离不变
    [button setImageEdgeInsets:UIEdgeInsetsMake(-button.titleLabel. intrinsicContentSize.height,(button.frame.size.width-button.imageView.bounds.size.width)/2.0,0.0,(button.frame.size.width-button.imageView.bounds.size.width)/2.0)];

}

相关文章

网友评论

      本文标题:调整button为上图片下文字

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