UIButton
iOS development
highlight control state
disable button highlight
Swift programming

How to disable the highlight control state of a UIButton?

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

UIButton enters the highlighted state automatically while the user is pressing it. You cannot really remove the existence of that control state, but you can stop it from producing a visible style change by keeping the highlighted appearance identical to the normal one or by overriding highlight behavior in a subclass.

What the Highlighted State Actually Is

The highlighted state is part of UIControl behavior. When a touch goes down inside the button, UIKit toggles isHighlighted and may dim the image, adjust the title, or trigger custom configuration changes depending on button type and styling.

That means the real question is usually not “how do I disable the state internally,” but “how do I prevent the user from seeing a different visual state.”

Keep Normal and Highlighted Appearance the Same

For many buttons, the simplest fix is to set the same assets and colors for .normal and .highlighted:

swift
1import UIKit
2
3let button = UIButton(type: .system)
4button.setTitle("Save", for: .normal)
5button.setTitle("Save", for: .highlighted)
6button.setTitleColor(.systemBlue, for: .normal)
7button.setTitleColor(.systemBlue, for: .highlighted)
8button.setBackgroundImage(UIImage(named: "buttonBg"), for: .normal)
9button.setBackgroundImage(UIImage(named: "buttonBg"), for: .highlighted)

If the visual assets are identical for both states, the highlight transition becomes effectively invisible.

This is usually enough for custom-styled buttons that rely on explicit images or title colors.

Override Highlight Behavior in a Subclass

If UIKit is still applying an unwanted dimming or state update, override isHighlighted and ignore the visual transition:

swift
1import UIKit
2
3final class NoHighlightButton: UIButton {
4    override var isHighlighted: Bool {
5        get { super.isHighlighted }
6        set { }
7    }
8}

This stops the button from reacting visually to the highlighted assignment.

A more conservative version preserves the internal state but forces appearance back to normal:

swift
1import UIKit
2
3final class StableButton: UIButton {
4    override var isHighlighted: Bool {
5        didSet {
6            if isHighlighted {
7                alpha = 1.0
8            }
9        }
10    }
11}

The exact override strategy depends on whether you want to suppress state changes entirely or only neutralize the visual effect.

Watch Button Type and Configuration APIs

Modern iOS buttons can be affected by UIButton.Configuration, tint behavior, and system button types. If you are using configuration-based buttons, update the configuration logic so the highlighted state does not apply a different appearance.

For example, if you set colors in one place but the configuration update handler changes them on highlight, the button may still flash or dim even though the base properties look correct.

That is why subclassing or consistent state configuration is often more reliable than changing one visual property in isolation.

UX Considerations

Removing highlight feedback has a tradeoff: the button may feel less responsive. In many designs, some touch feedback is useful, even if it is subtle.

A softer alternative is to replace the default highlight with a custom animation that fits the design better, such as a very small scale or background transition instead of a strong dimming effect.

So before disabling the effect completely, decide whether you are solving a visual bug or removing a helpful interaction cue.

Common Pitfalls

The biggest mistake is trying to disable highlight by setting only one property, such as the title color, while the button still changes image alpha or configuration elsewhere.

Another issue is forgetting that UIButton(type: .system) and custom-styled buttons can behave differently. The button type affects default rendering behavior.

Developers also sometimes override isHighlighted too aggressively and unintentionally interfere with accessibility or event expectations. Test the resulting button carefully.

Finally, if the problem comes from configuration-based styling on newer iOS versions, changing old-style state properties alone may not be enough.

Summary

  • You usually do not remove the highlighted state itself; you remove its visible effect.
  • The simplest fix is to make .normal and .highlighted look the same.
  • For stricter control, subclass UIButton and neutralize highlight updates.
  • Check button type and configuration-based styling on modern iOS.
  • Keep some touch feedback if possible so the button still feels responsive.

Course illustration
Course illustration

All Rights Reserved.