transformEffect

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

View ModifieriOS 13.0+macOS 10.15+tvOS 13.0+watchOS 6.0+transformEffect(_:) in SwiftUI

Declaration

React
compose().transformEffect(transform: CGAffineTransform)
Swift
nonisolated func transformEffect(
    _ transform: CGAffineTransform
) -> some View

Parameters

  • transform*CGAffineTransform

    A

Discussion

Use transformEffect(_:) to rotate, scale, translate, or skew the output of the view according to the provided doc://com.apple.documentation/documentation/CoreFoundation/CGAffineTransform.

In the example below, the text is rotated at -30˚ on the y axis.

let transform = CGAffineTransform(rotationAngle: -30 * (.pi / 180))

Text("Projection effect using transforms")
    .transformEffect(transform)
    .border(Color.gray)

doc://com.apple.documentation/documentation/CoreFoundation/CGAffineTransform to apply to the view.

See also

More in Visual effects.