UIButton上image和title的位置调整

来源:互联网 发布:博客数据库设计 编辑:程序博客网 时间:2024/05/19 21:59

UIButton上image和title的位置调整方法:

 //UIEdgeInsetsMake(top left bottom right)
 [button setImageEdgeInsets:UIEdgeInsetsMake(0.0, 100.0,0.0, 0.0)]; //将image的位置向右移动100个像素

 [button setTitleEdgeInsets:UIEdgeInsetsMake(0.0 , 100.0,0.0 , 0.0)]; ////将title的位置向右移动100个像素


//UIEdgeInsetsMake原型

UIKIT_STATIC_INLINE UIEdgeInsets UIEdgeInsetsMake(CGFloat top, CGFloat left, CGFloat bottom, CGFloat right) {
    UIEdgeInsets insets = {top, left, bottom, right};
    return insets;
}


原创粉丝点击