projectionEffect(_:)
Applies a projection transformation to this view’s rendered output.
Declaration
nonisolated func projectionEffect(_ transform: ProjectionTransform) -> some View
Parameters
- transform:
A Projectiontransform to apply to the view.
Discussion
Use projectionEffect(_:) to apply a 3D transformation to the view.
The example below rotates the text 30˚ around the z axis, which is the axis pointing out of the screen:
// This transform represents a 30˚ rotation around the z axis.
let transform = CATransform3DMakeRotation(
-30 * (.pi / 180), 0.0, 0.0, 1.0)
Text("Projection effects using transforms")
.projectionEffect(.init(transform))
.border(Color.gray)[Image]
See Also
Scaling, rotating, or transforming a view
scaledToFill()scaledToFit()scaleEffect(_:anchor:)scaleEffect(_:anchor:)scaleEffect(x:y:anchor:)scaleEffect(x:y:z:anchor:)aspectRatio(_:contentMode:)rotationEffect(_:anchor:)rotation3DEffect(_:axis:anchor:anchorZ:perspective:)perspectiveRotationEffect(_:axis:anchor:anchorZ:perspective:)rotation3DEffect(_:anchor:)rotation3DEffect(_:axis:anchor:)transformEffect(_:)transform3DEffect(_:)ProjectionTransform