关于titleEdgeInsets的使用

对于上下移动而言,取决于top和down的值,移动的距离为|top - down|/2,就是top减去down差的绝对值的一半,具体方向需要看这两个参数。左右的原理与上下一致。
A positive value shrinks, or insets, that edge—moving it closer to the center of the button. A negative value expands, or outsets, that edge,这句话是文档里的,意思就是如果参数值为正,那么相应方向将会向button的中心靠,负值,将会向外偏移。

现在只列举top与down来解释说明,分4种情况(参与运算的各参数一定要带符号)
1)top为正,down为正,移动的方向取决于值大的参数;如果top大于down,那么文字将向下移动,移动的距离为|top - down|/2,反之
2)top为正,down为负,移动的方向为向下;移动的距离为|top - down|/2
3)top为负,down为正,移动的方向为向上;移动的距离为|top - down|/2
4)top为负,down为负,移动的方向取决于绝对值大的参数;如果|top|大于|down|,那么文字将向上移动,移动的距离为|top - down|/2,反之

贴出文档中的描述
Discussion
Use this property to resize and reposition the effective drawing rectangle for the button title. You can specify a different value for each of the four insets (top, left, bottom, right). A positive value shrinks, or insets, that edge—moving it closer to the center of the button. A negative value expands, or outsets, that edge. Use the UIEdgeInsetsMake function to construct a value for this property. The default value is UIEdgeInsetsZero.

The insets you specify are applied to the title rectangle after that rectangle has been sized to fit the button’s text. Thus, positive inset values may actually clip the title text.

This property is used only for positioning the title during layout. The button does not use this property to determine intrinsicContentSize and sizeThatFits.

转载于:https://www.cnblogs.com/iOS-kk/p/5207272.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值