开发者

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.

How can I prevent a UIButton from highlighting when pressed?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜