跳转至
Structure

Form

A container for grouping controls used for data entry, such as in settings or inspectors.

Declaration

struct Form<Content> : View where Content : View

Overview

SwiftUI renders forms in a manner appropriate for the platform. For example, on iOS, forms appear as grouped lists. Use Section to group different parts of a form's content.

For example:

struct ExampleView: View {
    @State private var myFruit = ""

    var body: some View {
        Form {
            TextField("Banana 🍌", text: $myFruit)
            TextField("Banana 🍌", text: $myFruit)
            TextField("Banana 🍌", text: $myFruit)
        }
    }
}
Form Example 1

Availability

iOS 13.0+

macOS 10.15+

tvOS 13.0+

watchOS 6.0+

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(content:) Creates a form from a view builder containing child views.