How can I prevent UIButton from being highlighted when clicked?

When UIButton pressed UIButton normal situation is that it will be highlighted, i.e. a shadow layer will cover the image. Is there any way to prevent this? Is there an attribute for this?

+4
source share
3 answers

Usually you do not press a button using Xcode, you use your finger (or mouse). But disabling aside: adjustsImageWhenHighlighted set to NO will do the trick.

+7
source

If you create a custom subclass of UIButton, you can override setHighlighted: (BOOL) allocated to not do anything

 - (void)setHighlighted:(BOOL)highlighted { return; } 
+3
source

You can also achieve this through Interface Builder. Uncheck the "Select image substring" checkbox in the attribute inspector.

enter image description here

+2
source

All Articles