titleEdgeInsets Inserts or source fields for the edges of the rectangle of the draw button header.
@property (non-nuclear) UIEdgeInsets titleEdgeInsets
The discussion . Use this. property for resizing and changing the correct drawing rectangle for the button name. You can specify a different value for each of the four inserts (top, left, bottom, right). A positive value is compressed or pasted that intersect it closer to the center of the button. a negative value expands or goes around this edge. Use the UIEdgeInsetsMake Function to create a value for this property. The default value is UIEdgeInsetsZero.
Availability Available in iOS 2.0 and later.
Announced at UIButton.h
Try it :)
[myButton setTitleEdgeInsets:UIEdgeInsetsMake(0.0, 5.0, 0.0, 0.0)]
Also, if you use a custom button, there is such a thing as pasting content and pasting images.
Go, you did it here, looking for Swift. This is a valid Swift 3.0 😃
myButton.titleEdgeInsets = UIEdgeInsets(top: 0.0, left: 5.0, bottom: 0.0, right: 0.0)
You can also install it directly. Useful if you want to use one or two properties.
myButton.titleEdgeInsets.top = 0 myButton.titleEdgeInsets.left = 5 myButton.titleEdgeInsets.bottom = 0 myButton.titleEdgeInsets.right = 0
Ryan Poolos May 14 '12 at 18:45 2012-05-14 18:45
source share