ios - Change a UIButton's text (padding) programmatically in Swift -
still learning swift , don't know objective-c. saw in order changing button's text programmatically requires use of titleedgeinsets
not sure how use it.
i change text in button (padding) in bottom , both left , right.
thanks responses and/or examples!
ios 9.1/xcode 7.1/swift 2.1/osx 10.10.5
:
the method titleedgeinsets
didn't work me. button's frame tightly hugs text (i didn't specify frame size), , frame has red background color. after doing:
mybutton.titleedgeinsets = uiedgeinsetsmake(10,10,10,10)
the red background shrunk inwards 10 pixels on each side, meant of text outside red background. using negative values had no effect on original frame size.
i able padding around text, making frame bigger, doing:
mybutton.contentedgeinsets = uiedgeinsetsmake(5,5,5,5)
Comments
Post a Comment