美文网首页Objective C开发
iOS button 文字和图片位置的设置

iOS button 文字和图片位置的设置

作者: Jimsir | 来源:发表于2017-03-29 16:11 被阅读86次

    //文字距离上边框的距离增加imageView的高度,距离左边框减少imageView的宽度,距离下边框和右边框距离不变
    [_customerBtn setTitleEdgeInsets:UIEdgeInsetsMake(_customerBtn.imageView.frame.size.height+10 ,-_customerBtn.imageView.frame.size.width, 0.0,0.0)];

    //图片距离右边框距离减少图片的宽度,其它不边左右:(因为默认button 图片在左,文字在右, 下面代码是反过来的: 文字 图片)
    [_customerBtn setImageEdgeInsets:UIEdgeInsetsMake(-18, 0.0,0.0, - _customerBtn.titleLabel.bounds.size.width)];

    相关文章

      网友评论

        本文标题:iOS button 文字和图片位置的设置

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