rotation

Rotates this shape around an anchor point at the angle you specify.

Shape ModifieriOS 13.0+macOS 10.15+tvOS 13.0+watchOS 6.0+rotation(_:anchor:) in SwiftUI

Declaration

React
compose().rotation(
  angle: SwiftUI.Angle,
  options?: {
    anchor?: SwiftUI.UnitPoint;
  }
)
Swift
nonisolated func rotation(
    _ angle: Angle,
    anchor: UnitPoint = .center
) -> RotatedShape<Self>

Parameters

  • The angle of rotation to apply. Positive angles rotate clockwise; negative angles rotate counterclockwise.

  • options.anchorSwiftUI.UnitPoint

    The point to rotate the shape around.

Return value

A rotated shape.

Discussion

The following example rotates a square by 45 degrees to the right to create a diamond shape:

RoundedRectangle(cornerRadius: 10)
.rotation(Angle(degrees: 45))
.aspectRatio(1.0, contentMode: .fit)

See also

More in Shape modifiers.