Reputation: 17622
I have a UIButton with a custom background that I set in the Interface Builder (see picture). It looks nice, but in the pressed state it gets really ugly (see the 2nd picture). What's going on here?
Normal:
Pressed:
Upvotes: 0
Views: 576
Reputation: 9933
Post some code or maybe the image itself. It looks as if you might need to declare your 'pressed' image with one of UIImage
's resizableImage*
methods. It's stretching to fill the button rect.
Also, I'm fond of the MOButton
and MOGlassButton
classes used in the iPhone SOCKS project (handy in itself).
Update
The following worked for me, it even animated it dark when pressed:
Upvotes: 0
Reputation: 1587
[btn setBackgroundImage:[[UIImage imageNamed:@"button_red.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(12, 12, 20, 12)] forState:UIControlStateNormal];
[btn setBackgroundImage:[[UIImage imageNamed:@"button_red_pressed.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(12, 12, 20, 12)] forState:UIControlStateHighlighted];
This should solve the problem.
Also, change your button style to Custom, this will remove that blue button background.
Upvotes: 1