Declaration
compose().blur({
radius: number,
opaque?: boolean,
})nonisolated func blur(
radius: CGFloat,
opaque: Bool = false
) -> some ViewParameters
options.radius*numberThe radial size of the blur. A blur is more diffuse when its radius is large.
options.opaquebooleanA Boolean value that indicates whether the blur renderer permits transparency in the blur output. Set to
trueto create an opaque blur, or set tofalseto 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.
- allowedDynamicRangeReturns a new view configured with the specified allowed dynamic range.
- backgroundExtensionEffectAdds the background extension effect to the view. The view will be duplicated into mirrored copies which will be placed around the view on any edge with available safe area. Additionally, a blur effect will be applied on top to blur out the copies.
- brightnessBrightens this view by the specified amount.
- clippedClips this view to its bounding rectangular frame.
- colorEffectReturns a new view that applies shader to self as a filter effect on the color of each pixel.
- colorInvertInverts the colors in this view.
- colorMultiplyAdds a color multiplication effect to this view.
- compositingGroupWraps this view in a compositing group.
- contrastSets the contrast and separation between similar colors in this view.
- distortionEffectReturns a new view that applies shader to self as a geometric distortion effect on the location of each pixel.
- drawingGroupComposites this view's contents into an offscreen image before final display.
- glassEffectApplies a glass effect to this view.