Instance Property インスタンスプロパティ

body

A rectangular view that’s filled with the shape style.

Declaration 宣言

var body: _ShapeView<Rectangle, Self> { get }
Available when Self conforms to View and Body is _ShapeView<Rectangle, Self>. SelfViewに準拠するそしてBody_ShapeView<Rectangle, Self>である時に利用可能です。

Discussion 議論

For a ShapeStyle that also conforms to the View protocol, like Color or LinearGradient, this default implementation of the body property provides a visual representation for the shape style. As a result, you can use the shape style in a view hierarchy like any other view:


ZStack {
    Color.cyan
    Text("Hello!")
}
.frame(width: 200, height: 50)

A screenshot of a cyan rectangle with the text hello appearing