Instance Method

projectionEffect(_:)

Applies a projection transformation to this view’s rendered output.

Declaration

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)
A screenshot showing text rotated 30 degrees around the axis pointing out of the screen.

See Also

Rotating and Transforming Views

func rotationEffect(Angle, anchor: UnitPoint) -> View

Rotates this view’s rendered output around the specified point.

func transformEffect(CGAffineTransform) -> View

Applies an affine transformation to this view’s rendered output.