跳转至
Structure

ProjectionTransform

A projection transform is a type of spacial transformation of an object that can be represented as a 3x3 matrix.

Declaration

@frozen struct ProjectionTransform

Overview

Use this structure to apply a 3D transformation to a view.

Conceptually, this structure represents a 3D transformation matrix. Each column of the matrix represents where the unit vector of the original view lands in the transformed view. The x unit vector is represented by the left column, the y unit vector is represented by the middle column, and the z unit vector is represented by the right column.

Making a ProjectionTransform

Constructing a ProjectionTransform is most commonly done in one of three ways:

See below for an example.

Using a ProjectionTransform

The primary way to use a ProjectionTransform is by using the projectionEffect(_:) modifier.

struct UpsideDownTrashCanView: View {
    let effect = ProjectionTransform(CGAffineTransform(rotationAngle: .pi))

    var body: some View {
        Text("🗑")
            .font(.title)
            .projectionEffect(effect)
    }
}
471A4641-6C43-4407-A9E5-9DD446D77365

Availability

iOS 13.0+

macOS 10.15+

tvOS 13.0+

watchOS 6.0+

Topics


Initializer

init() Creates a projection transform equal to the identity matrix.

init(_:) Creates a projection transform from a CATransform3D.

init(_:) Creates a projection transform from a CGAffineTransform.


Type Method

==(a:b:) Returns a Boolean value indicating whether two values are equal.


Instance Method

concatenating(_:) Concatenates two projection transform matrices together to make a new one.

invert() Inverts the projection transform matrix if it's invertible.

inverted() Modifies the projection transform to its inverse if invertable.


Instance Property

isAffine Whether the projection transform matrix is an affine transform.

isIdentity Whether the projection transform matrix is an identity matrix.

m11 The top left value in the projection transform matrix.

m12 The top middle value in the projection transform matrix.

m13 The top right value in the projection transform matrix.

m21 The center left value in the projection transform matrix.

m22 The center value in the projection transform matrix.

m23 The center right value in the projection transform matrix.

m31 The bottom left value in the projection transform matrix.

m32 The bottom center value in the projection transform matrix.

m33 The bottom right value in the projection transform matrix.