Graphics and rendering modifiers
Affect the way the system draws a view, for example by scaling or masking a view, or by applying graphical effects.
Overview
Use these view modifiers to apply many of the rendering effects typically associated with a graphics context, like adding masks and creating composites. You can apply these effects to graphical views, like Shapes, as well as any other SwiftUI view.
When you do need the flexibility of immediate mode drawing in a graphics context, use a Canvas view instead. This can be particularly helpful when you want to draw an extremely large number of dynamic shapes — for example, to create particle effects.
For more information about using these effects in your app, see Drawing and graphics.
Topics
Masks and clipping
Scale
scaledToFill()scaledToFit()scaleEffect(_:anchor:)scaleEffect(x:y:anchor:)scaleEffect(x:y:z:anchor:)imageScale(_:)aspectRatio(_:contentMode:)
Rotation and transformation
rotationEffect(_:anchor:)rotation3DEffect(_:anchor:)rotation3DEffect(_:axis:anchor:anchorZ:perspective:)rotation3DEffect(_:axis:anchor:)perspectiveRotationEffect(_:axis:anchor:anchorZ:perspective:)projectionEffect(_:)transformEffect(_:)transform3DEffect(_:)
Graphical effects
blur(radius:opaque:)opacity(_:)brightness(_:)contrast(_:)colorInvert()colorMultiply(_:)saturation(_:)grayscale(_:)hueRotation(_:)luminanceToAlpha()shadow(color:radius:x:y:)visualEffect(_:)visualEffect3D(_:)
Shaders
colorEffect(_:isEnabled:)distortionEffect(_:maxSampleOffset:isEnabled:)layerEffect(_:maxSampleOffset:isEnabled:)
Composites
Animations
animation(_:)animation(_:value:)animation(_:body:)keyframeAnimator(initialValue:repeating:content:keyframes:)keyframeAnimator(initialValue:trigger:content:keyframes:)phaseAnimator(_:content:animation:)phaseAnimator(_:trigger:content:animation:)contentTransition(_:)transition(_:)transaction(_:)transaction(value:_:)transaction(_:body:)contentTransition(_:)matchedGeometryEffect(id:in:properties:anchor:isSource:)geometryGroup()