UIButton Text Margin / Padding

后端 未结 9 1127
名媛妹妹
名媛妹妹 2021-01-31 13:39

I have the following layout, and I\'m trying to add a padding to the left and right..

The controls are a disabled UIButton.

9条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-31 13:55

    // Swift
    var titleEdgeInsets: UIEdgeInsets!
    
    // Objective-C
    @property(nonatomic) UIEdgeInsets titleEdgeInsets;
    

    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.

    https://developer.apple.com/documentation/uikit/uibutton/1624010-titleedgeinsets

提交回复
热议问题