Instance Method

rotation(_:anchor:)

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

Declaration

func rotation(_ angle: Angle, anchor: UnitPoint = .center) -> RotatedShape<Rectangle>

Parameters

angle

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

anchor

The point to rotate the shape around.

Return Value

A rotated shape.

Discussion

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

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