Shape ModifieriOS 13.0+macOS 10.15+tvOS 13.0+watchOS 6.0+
Overloads
3 ways to call compose().offset(). Each is one SwiftUI overload, picked by the arguments you pass.
compose().offset(offset: CGSize)nonisolated func offset(_ offset: CGSize) -> OffsetShape<Self>Parameters
offset*CGSizeThe amount, in points, by which you offset the shape. Negative numbers are to the left and up; positive numbers are to the right and down.
Return value
A shape offset by the specified amount.
Discussion
The following example renders two circles. It places one circle at its default position. The second circle is outlined with a stroke, positioned on top of the first circle and offset by 100 points to the left and 50 points below.
Circle()
.overlay(
Circle()
.offset(CGSize(width: -100, height: 50))
.stroke()
)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.
- pathDescribes this shape as a path within a rectangular frame of reference.
- rotationRotates this shape around an anchor point at the angle you specify.
- 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.