VisualEffect

Visual Effects change the visual appearance of a view without changing its ancestors or descendents.

ProtocoliOS 17.0+macOS 14.0+tvOS 17.0+watchOS 10.0+VisualEffect in SwiftUI

Declaration

React
type VisualEffect = SwiftOpaque<'VisualEffect'>;
Swift
protocol VisualEffect : Sendable, Animatable

Overview

Because effects do not impact layout, they are safe to use in situations where layout modification is not allowed. For example, effects may be applied as a function of position, accessed through a geometry proxy:

var body: some View {
    ContentRow()
        .visualEffect { content, geometryProxy in
            content.offset(x: geometryProxy.frame(in: .global).origin.y)
        }
}

You don't conform to this protocol yourself. Instead, visual effects are created by calling modifier functions (such as .offset(x:y:) on other effects, as seen in the example above.

From Apple’s SwiftUI documentation. Code samples there are Swift.

See also

More in Visual effects.