Skip to main content
.allowsHitTesting(enabled: boolean)
enabled
boolean
required
When false, the component and all its descendants become transparent to touch and click events. Events pass through to views behind it.

Support

Usage

Make an overlay pass through touches

ZStack([
    Button("Tap me", () => handleTap()),
    Color("black")
        .opacity(0.3)
        .allowsHitTesting(false)
])

Disable interaction on a watermark

Image({ url: "watermark.png" })
    .resizable()
    .allowsHitTesting(false)

Notes

Unlike disabled, allowsHitTesting(false) does not dim the component visually. It only affects whether the component receives interaction events.

See Also