How can I prevent a UIButton from highlighting when pressed?
When an UIButton
is pressed, the normal situation is that it will be highlighted i.e. a shadow like layer will cover the image. Is there a way to prevent this from happening? Is t开发者_Go百科here an attribute to handle this?
You normally don't press a button with Xcode, you use your finger (or mouse). But nitpicking aside: adjustsImageWhenHighlighted
set to NO
will do the trick.
If you make a custom subclass of the UIButton you can override setHighlighted:(BOOL)highlighted to do nothing
- (void)setHighlighted:(BOOL)highlighted
{
return;
}
You can also achieve this through Interface Builder. Uncheck "Highlighted Adjusts Image" in the Attributes inspector.
精彩评论