First create a stretchable UIImage(this assumes the “cap” at the end of your button image is 10px):
UIImage *backgroundImage = [[UIImage imageNamed:@"ImageBackground.png"] stretchableImageWithLeftCapWidth:10 topCapHeight:0];
Then use the stretch image as the background:
[myButton setBackgroundImage:backgroundImage forState:UIControlStateNormal]
When you set backgroundImage UIButtonto UIControlStateNormal, it acts as a background for all states unless you explicitly set another backgroundImage for any of the other states.