uibutton图片 文字上下居中

xiaoxiao2021-02-28  10

//调整图片和文字上下显示      focusBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;//使图片和文字水平居中显示      [focusBtn setTitleEdgeInsets:UIEdgeInsetsMake(focusBtn.imageView.frame.size.height ,-focusBtn.imageView.frame.size.width0.0,0.0)];//文字距离上边框的距离增加imageView的高度,距离左边框减少imageView的宽度,距离下边框和右边框距离不变      [focusBtn setImageEdgeInsets:UIEdgeInsetsMake(-focusBtn.imageView.frame.size.height0.0,0.0, -focusBtn.titleLabel.bounds.size.width)]; 
转载请注明原文地址: https://www.6miu.com/read-2150017.html

最新回复(0)