跳转至
Structure

Group

A structure that groups other structure together.

Declaration

@frozen struct Group<Content>

Overview

Use this structure to group together structures of different types. There are five different types of groups. Each groups together a type of content.

  1. ToolbarContent
  2. CustomizableToolbarContent
  3. Scene
  4. View
  5. Commands

There are 2 main reasons to use a Group:

  • To exceed the 10 struct limitation of a function builder
  • To improve code readability.

Here is an example creating a Group of Views:

struct ExampleView: View {
    var body: some View {
        Group {
            Text("1")
            Text("2")
            Text("3")
            Text("4")
            Text("5")
        }
    }
}

Availability

iOS 13.0+

macOS 10.15+

tvOS 13.0+

watchOS 6.0+

Topics


Type Alias

Body The type of content representing the body of this toolbar content.


Initializer

init(content:) Creates a Group from command content.

init(content:) Creates a Group from a customizable toolbar content.

init(content:) Creates a Group from view content.

init(content:) Creates a Group from a customizable toolbar content.

init(content:) Creates a Group from component scenes.