blur

Applies a Gaussian blur to this view.

View ModifieriOS 13.0+macOS 10.15+tvOS 13.0+watchOS 6.0+blur(radius:opaque:) in SwiftUI

Declaration

React
compose().blur({
  radius: number,
  opaque?: boolean,
})
Swift
nonisolated func blur(
    radius: CGFloat,
    opaque: Bool = false
) -> some View

Parameters

  • options.radius*number

    The radial size of the blur. A blur is more diffuse when its radius is large.

  • options.opaqueboolean

    A Boolean value that indicates whether the blur renderer permits transparency in the blur output. Set to true to create an opaque blur, or set to false to permit transparency.

Discussion

Use blur(radius:opaque:) to apply a gaussian blur effect to the rendering of this view.

The example below shows two Text views, the first with no blur effects, the second with blur(radius:opaque:) applied with the radius set to 2. The larger the radius, the more diffuse the effect.

struct Blur: View {
    var body: some View {
        VStack {
            Text("This is some text.")
                .padding()
            Text("This is some blurry text.")
                .blur(radius: 2.0)
        }
    }
}

See also

More in Visual effects.