Fix: UIButton Highlight State Not Disabling When Tapped in UIKit

Written by

in

Quick answer: Set the button type to Custom, then disable ‘Highlight Adjusts Image’ in Interface Builder or set button.adjustsImageWhenHighlighted = false in code. This prevents the visual highlight state when the button is tapped.

Why this happens

UIButton applies a default highlight effect when touched, dimming or tinting the button’s image and title. This behavior is built into the system button types (System, Detail Disclosure, Info Light, etc.) and cannot be turned off on those types. The highlight state is part of UIControl‘s standard interaction feedback, but it often conflicts with custom designs where you want the button to remain visually static during touch.

The key requirement is that the button must use the Custom type. Only Custom buttons expose the adjustsImageWhenHighlighted and adjustsImageWhenDisabled properties that let you suppress the automatic highlight and dimming adjustments.

How to fix it

1. Disable highlight in Interface Builder

  1. Select the button in your storyboard or xib.
  2. Open the Attributes Inspector (⌘⌥4).
  3. Change Type to Custom.
  4. Uncheck Highlight Adjusts Image.
  5. Optionally uncheck Disabled Adjusts Image if you also want to prevent dimming when the button is disabled.

This is the fastest method for buttons created in storyboards or xibs.

2. Disable highlight programmatically

When creating buttons in code, set the type to .custom and toggle the adjustment properties:

import UIKit

let button = UIButton(type: .custom)
button.adjustsImageWhenHighlighted = false
button.adjustsImageWhenDisabled = false
// Configure title, image, target/action, etc.

If you already have a reference to a button (for example, from an @IBOutlet), just ensure its type is Custom and then set the properties:

@IBOutlet private weak var actionButton: UIButton!

override func viewDidLoad() {
    super.viewDidLoad()
    // Button must be Custom type in the storyboard for this to work
    actionButton.adjustsImageWhenHighlighted = false
    actionButton.adjustsImageWhenDisabled = false
}

3. Use a custom background image for full control

If you need a completely custom pressed appearance, supply your own images for each state instead of relying on the automatic highlight:

let button = UIButton(type: .custom)
button.setBackgroundImage(normalImage, for: .normal)
button.setBackgroundImage(pressedImage, for: .highlighted)
button.setBackgroundImage(disabledImage, for: .disabled)
button.adjustsImageWhenHighlighted = false
button.adjustsImageWhenDisabled = false

This approach gives you pixel-perfect control over every visual state.

How to prevent it

  • Always choose Custom button type when you need non-standard highlight behavior.
  • Set adjustsImageWhenHighlighted = false immediately after button creation or in viewDidLoad for outlets.
  • Pair the property with adjustsImageWhenDisabled = false to keep the disabled appearance consistent.
  • Avoid System, Detail Disclosure, or other built-in types when you need to suppress the default highlight.

FAQ

Does this work on system button types like .system or .detailDisclosure?

No. The adjustsImageWhenHighlighted property only takes effect when buttonType is .custom. System buttons always apply the default highlight tint.

Can I disable the highlight for just the title text but keep it for the image?

Not with the built-in property. adjustsImageWhenHighlighted affects both image and title rendering together. For granular control, use custom background images per state or a subclass that overrides setHighlighted(_:animated:).

Will disabling the highlight affect accessibility or user feedback?

Removing the visual highlight reduces the default touch feedback. If you disable it, provide an alternative cue such as a custom pressed-state image, haptic feedback via UIImpactFeedbackGenerator, or a subtle scale animation so users still perceive the interaction.

Sources & credits

Parts of this guide are adapted from content licensed under CC BY-SA 3.0; this article is shared under the same license.