iOS 的那些事儿

如何理解UIButton的imageEdgeInsets和tit

2017-08-11  本文已影响399人  mobilefellow

理论

var imageEdgeInsets: UIEdgeInsets { get set }

Use this property to resize and reposition the effective drawing rectangle for the button image. 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.

var titleEdgeInsets: UIEdgeInsets { get set }

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.

官方文档对于这个两个属性的解释如上,老实说,非常不直观,看完依然不懂。要理解titleEdgeInsets,可以从以下几方面考虑(imageEdgeInsets的理解与titleEdgeInsets完全一致):

上一篇下一篇

猜你喜欢

热点阅读