rotationEffect

Rotates a view's rendered output in two dimensions around the specified point.

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

Declaration

React
compose().rotationEffect(
  angle: SwiftUI.Angle,
  options?: {
    anchor?: SwiftUI.UnitPoint;
  }
)
Swift
nonisolated func rotationEffect(
    _ angle: Angle,
    anchor: UnitPoint = .center
) -> some View

Parameters

Return value

A view with rotated content.

Discussion

This modifier rotates the view's content around the axis that points out of the xy-plane. It has no effect on the view's frame. The following code rotates text by 22˚ and then draws a border around the modified view to show that the frame remains unchanged by the rotation modifier:

Text("Rotation by passing an angle in degrees")
    .rotationEffect(.degrees(22))
    .border(Color.gray)

See also

More in Visual effects.