Structure¶
ContainerRelativeShape¶
A shape that is replaced by an inset version of the current container shape. If no container shape was defined, is replaced by a rectangle.¶
Declaration¶
@frozen struct ContainerRelativeShape : Shape
Overview¶
Use this shape primarily with widgets. It generates container-relative rounded rectangles.
The example below is generated by going to
File > New > Target
Then search for "Widget Extension", click Next, give it a Product Name, then click Finish. In the new .swift file, edit the View:
struct TimeEntryView: View {
var entry: Provider.Entry
var body: some View {
VStack {
ContainerRelativeShape()
.fill(Color.yellow)
.overlay(Text("Time"))
ContainerRelativeShape()
.fill(Color.blue)
.overlay(Text(entry.date, style: .time))
}
}
}

Availability¶
iOS 14.0+
macOS 11.0+
tvOS 14.0+
watchOS 7.0+
Topics¶
Initializer¶
init() Creates a relative container shape.
Type Alias¶
AnimatableData The type defining the data to animate.
Body The type of view representing the body of this view.
InsetShape The type of the inset shape.
Instance Method¶
inset(by:) Returns self inset by amount.
path(in:) Describes this shape as a path within a rectangular frame of reference.