美文网首页tips
UIbutton 上下图片文字布局

UIbutton 上下图片文字布局

作者: crazyfox | 来源:发表于2018-07-05 14:50 被阅读25次
//设置文字偏移:向下偏移图片高度+向左偏移图片宽度 (偏移量是根据[图片]大小来的,这点是关键)
_baseInfoButton.titleEdgeInsets = UIEdgeInsetsMake(_baseInfoButton.imageView.frame.size.height, -_baseInfoButton.imageView.frame.size.width, 0, 0);

//设置图片偏移:向上偏移文字高度+向右偏移文字宽度 (偏移量是根据[文字]大小来的,这点是关键)
_baseInfoButton.imageEdgeInsets = UIEdgeInsetsMake(-_baseInfoButton.titleLabel.frame.size.height,0,0,-_baseInfoButton.titleLabel.bounds.size.width);

相关文章

网友评论

    本文标题:UIbutton 上下图片文字布局

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