UIButton共有三个相关属性:
1.contentEdgeInsets
2.titleEdgeInsets
3.imageEdgeInsets
UIEdgeInsets
先来看看这个UIEdgeInsets:
typedef struct UIEdgeInsets {
CGFloat top, left, bottom, right; // specify amount to inset (positive) for each of the edges. values can be negative to 'outset'
} UIEdgeInsets;
原来是结构体,它的四个参数:top, left, bottom, right, 分别表示距离上边界,左边界,下边界,右边界的位移,默认值均为0。
imageEdgeInsets left 相对于按钮,默认为0.正数向右偏,负数向左偏
imageEdgeInsets top 相对于按钮,正数向下偏,负数向上偏
imageEdgeInsets right 相对于title,正数向左偏,负数向右偏
imageEdgeInsets bottom 相对于按钮,正数向上偏,负数向下偏
titleEdgeInsets跟imageEdgeInsets类似,但是titleEdgeInsets的left是相对于image的
网友评论