Declaration
compose().rotation(
angle: SwiftUI.Angle,
options?: {
anchor?: SwiftUI.UnitPoint;
}
)nonisolated func rotation(
_ angle: Angle,
anchor: UnitPoint = .center
) -> RotatedShape<Self>Parameters
angle*SwiftUI.AngleThe angle of rotation to apply. Positive angles rotate clockwise; negative angles rotate counterclockwise.
options.anchorSwiftUI.UnitPointThe 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.
- fillFills this shape with a color or gradient.
- intersectionReturns a new shape with filled regions common to both shapes.
- lineIntersectionReturns a new shape with a line from this shape that overlaps the filled regions of the given shape.
- lineSubtractionReturns a new shape with a line from this shape that does not overlap the filled region of the given shape.
- offsetChanges the relative position of this shape using the specified size.
- pathDescribes this shape as a path within a rectangular frame of reference.
- scaleScales this shape without changing its bounding frame.
- sizeReturns a new version of self representing the same shape, but that will ask it to create its path from a rect of size. This does not affect the layout properties of any views created from the shape (e.g. by filling it).
- strokeTraces the outline of this shape with a color or gradient.
- subtractingReturns a new shape with filled regions from this shape that are not in the given shape.
- symmetricDifferenceReturns a new shape with filled regions either from this shape or the given shape, but not in both.
- transformApplies an affine transform to this shape.