需求:
有图片和文字的按钮,大部分时候不满足UI设计,所以需要微调。
思路
UIButton 提供了 titleEdgeInsets 与 imageEdgeInsets 属性
问题
titleEdgeInsets、imageEdgeInsets怎么设置
解答
if 内容的高 + |top - bottom| > 按钮的高 {
top - bottom 为内容下移的距离(负数上移)
} else {
// top 为内容的 y,bottom为内容的maxY
y = top
height = bottom - top
}
它们是 UIEdgeInsets 类型
有 top、bottom、left、right四个属性分别表示 上、下、左、右边距。top 和 bottom 决定了 内容的 y 与 height,left 和 right 决定了 内容的 x 与 width。
网友评论