iPhone SwiftUI layouts

Explore SwiftUI APIs, components, and modifiers with interactive iPhone previews, Swift code, and Apple documentation. Compare every available orientation, appearance, and design.

Button

EditButton

A button that toggles the edit mode environment value

Explore EditButton on iPhone in portrait, with SwiftUI code and Apple API documentation.

@Environment(\.editMode) private var editMode
@State private var name = "Foo"

var body: some View {
    HStack {
        if editMode?.wrappedValue.isEditing == true {
            TextField("Name", text: $name)
        } else {
            Text(name)
        }
        EditButton()
    }
}
iOS 13.0+ iPadOS 13.0+ visionOS 1.0+

Every available iPhone screenshot for EditButton.

2 views