Shape
A 2D shape that you can use when drawing a view.
Declaration
type Shape =
| 'buttonBorder'
| 'capsule'
| 'circle'
| 'containerRelative'
| 'ellipse'
| 'rect'
| 'textInputBorder'
| { capsule: { style: RoundedCornerStyle; }; }
| { rect: { cornerRadii: RectangleCornerRadii; style?: RoundedCornerStyle; }; }
| { rect: { cornerRadius: number; style?: RoundedCornerStyle; }; }
| { rect: { corners: EdgeCornerStyle; isUniform?: boolean; }; }
| { rect: { cornerSize: CGSize; style?: RoundedCornerStyle; }; }
| { rect: { topLeadingCorner: EdgeCornerStyle; topTrailingCorner: EdgeCornerStyle; bottomLeadingCorner: EdgeCornerStyle; bottomTrailingCorner: EdgeCornerStyle; }; }
| { rect: { topLeadingRadius?: number; bottomLeadingRadius?: number; bottomTrailingRadius?: number; topTrailingRadius?: number; style?: RoundedCornerStyle; }; }
| { rect: { uniformBottomCorners: EdgeCornerStyle; topLeadingCorner: EdgeCornerStyle; topTrailingCorner: EdgeCornerStyle; }; }
| { rect: { uniformLeadingCorners: EdgeCornerStyle; topTrailingCorner: EdgeCornerStyle; bottomTrailingCorner: EdgeCornerStyle; }; }
| { rect: { uniformLeadingCorners: EdgeCornerStyle; uniformTrailingCorners: EdgeCornerStyle; }; }
| { rect: { uniformTopCorners: EdgeCornerStyle; bottomLeadingCorner: EdgeCornerStyle; bottomTrailingCorner: EdgeCornerStyle; }; }
| { rect: { uniformTopCorners: EdgeCornerStyle; uniformBottomCorners: EdgeCornerStyle; }; }
| { rect: { uniformTrailingCorners: EdgeCornerStyle; topLeadingCorner: EdgeCornerStyle; bottomLeadingCorner: EdgeCornerStyle; }; }
| ButtonBorderShape
| Capsule
| Circle
| ConcentricRectangle
| ContainerRelativeShape
| DefaultGlassEffectShape
| Ellipse
| InsettableShape
| Path
| Rectangle
| RoundedRectangle
| RoundedRectangularShape
| ShapeChain
| ShapeDeclaration
| TextInputBorderShape
| UnevenRoundedRectangle;nonisolated protocol Shape : Sendable, Animatable, ViewPass a literal, or build one with SwiftUI.Shape from import { SwiftUI } from 'swiftui-react-native'.
Type properties
'capsule'SwiftUI.Shape.capsuleA capsule shape aligned inside the frame of the view containing it.
'circle'SwiftUI.Shape.circleA circle centered on the frame of the view containing it.
'containerRelative'SwiftUI.Shape.containerRelativeA shape that is replaced by an inset version of the current container shape. If no container shape was defined, is replaced by a rectangle.
'ellipse'SwiftUI.Shape.ellipseAn ellipse aligned inside the frame of the view containing it.
'rect'SwiftUI.Shape.rectA rectangular shape aligned inside the frame of the view containing it.
'textInputBorder'SwiftUI.Shape.textInputBorderA shape that defers to the environment to determine the resolved text input border shape.
Type methods
Overview
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.
From Apple’s SwiftUI documentation. Code samples there are Swift.
Used by
- AnyShapeA type-erased shape value.
- OffsetShapeA shape with a translation offset transform applied to it.
- RotatedShapeA shape with a rotation transform applied to it.
- ScaledShapeA shape with a scale transform applied to it.
- TransformedShapeA shape with an affine transform applied to it.
- backgroundSets the view's background to a style.
- clipShapeSets a clipping shape for this view.
- contentShapeSets the content shape for this view.
- glassEffectApplies a glass effect to this view.
- overlayLayers the specified style in front of this view.
- 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.
- 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.
- unionReturns a new shape with filled regions in either this shape or the given shape.
See also
More in Drawing and shapes.
- AngleA geometric angle whose value you access in either radians or degrees.
- AngularGradientAn angular gradient.
- AnyGradientA color gradient.
- BlendModeModes for compositing a view with overlapping content.
- ButtonBorderShapeA shape used to draw a button's border.
- ColorMatrixA matrix to use in an RGBA color transformation.
- ConcentricRectangleAnimatableDataThe type defining the data to animate.
- ContainerRelativeShapeA shape that is replaced by an inset version of the current container shape. If no container shape was defined, is replaced by a rectangle.
- ContentShapeKindsA kind for the content shape of a view.
- CoordinateSpaceProtocolA frame of reference within the layout system.
- DefaultGlassEffectShapeThe default shape applied by glass effects, a capsule.
- EllipticalGradientA radial gradient that draws an ellipse.