跳转至
Structure

GroupBox

A stylized view with an optional label that is associated with a logical grouping of content.

Declaration

struct GroupBox<Label, Content> : View where Label : View, Content : View

Overview

You create a GroupBox by providing an optional label, which describes the grouping of UI elements within, and the actual content. For example:

struct ContentView: View {
    var body: some View {
        GroupBox(label: Label("GroupBox Label", systemImage: "smiley"))
        {
            Text("Content within GroupBox")
            Text("More text content!")
        }
    }
}
A view containing a GroupBox with the label "GroupBox Label" paired with a smiley face systemImage and two text view contained wihtin.

Availability

iOS 14.0+

macOS 10.15+

Topics


Type Alias

Body The type of view representing the body of this view.


Instance Property

body The content and behavior of the view.


Initializer

init(_:) Creates an instance representing the configuration of a GroupBoxStyle.

init(content:) Creates a group box from only content, without including a label.

init(label:content:) Creates a group box from a label and a view builder of content.