Shape
A 2D shape that you can use when drawing a view.
Declaration
protocol Shape : Sendable, Animatable, View, _RemoveGlobalActorIsolationOverview
Shapes without an explicit fill or stroke get a default fill based on the foreground color.
You can define shapes in relation to an implicit frame of reference, such as the natural size of the view that contains it. Alternatively, you can define shapes in terms of absolute coordinates.
Topics
Getting standard shapes
buttonBordercapsulecapsule(style:)circlecontainerRelativeellipserectrect(cornerRadii:style:)rect(cornerRadius:style:)rect(cornerSize:style:)rect(topLeadingRadius:bottomLeadingRadius:bottomTrailingRadius:topTrailingRadius:style:)
Defining a shape’s size and path
Transforming a shape
trim(from:to:)transform(_:)size(_:)size(width:height:)scale(_:anchor:)scale(x:y:anchor:)rotation(_:anchor:)offset(_:)offset(x:y:)
Setting the stroke characteristics
stroke(_:lineWidth:)stroke(_:lineWidth:antialiased:)stroke(lineWidth:)stroke(_:style:)stroke(_:style:antialiased:)stroke(style:)
Filling a shape
Setting the role
Indicating a layout direction
Performing operations on a shape
intersection(_:eoFill:)lineIntersection(_:eoFill:)lineSubtraction(_:eoFill:)subtracting(_:eoFill:)symmetricDifference(_:eoFill:)union(_:eoFill:)
Instance Methods
Type Methods
rect(corners:isUniform:)rect(topLeadingCorner:topTrailingCorner:bottomLeadingCorner:bottomTrailingCorner:)rect(uniformBottomCorners:topLeadingCorner:topTrailingCorner:)rect(uniformLeadingCorners:topTrailingCorner:bottomTrailingCorner:)rect(uniformLeadingCorners:uniformTrailingCorners:)rect(uniformTopCorners:bottomLeadingCorner:bottomTrailingCorner:)rect(uniformTopCorners:uniformBottomCorners:)rect(uniformTrailingCorners:topLeadingCorner:bottomLeadingCorner:)