I am looking to create a Custom UIButton (not subclass) progrmatically, I would like it to have a background image that will stretch as the UIButton’s width increases. How would I do this?
I am looking to create a Custom UIButton (not subclass) progrmatically, I would like
Share
First create a stretchable
UIImage(this assumes the ‘cap’ at the end of your button image is 10px):Then use the stretchable image as the background:
When you set the backgroundImage on a
UIButtonforUIControlStateNormal, it acts as the background for all states, unless you explicitly set a different backgroundImage for any of the other states.