One Logo Pool Ball
SwiftUI · IOS API REFERENCE

EditButton

struct · iOS 13.0+ · SDK 27.1

nonisolated struct EditButton

A button that toggles the edit mode environment value. An edit button toggles the environment's ``EnvironmentValues/editMode`` value for content within a container that supports edit mode. In the following example, an edit button placed inside a ``NavigationView`` supports editing of a ``List``: @State private var fruits = [ "Apple", "Banana", "Papaya", "Mango" ] var body: some View { NavigationView { List { ForEach(fruits, id: \.self) { fruit in Text(fruit) } .onDelete { fruits.remove(atOffsets: $0) } .onMove { fruits.move(fromOffsets: $0, toOffset: $1) } } .navigationTitle("Fruits") .toolbar { EditButton() } } } Because the ``ForEach`` in the above example defines behaviors for ``DynamicViewContent/onDelete(perform:)`` and ``DynamicViewContent/onMove(perform:)``, the editable list displays the delete and move UI when the user taps Edit. Notice that the Edit button displays the title "Done" while edit mode is active: ![A screenshot of an app with an Edit button in the navigation bar. The button is labeled Done to indicate edit mode is active. Below the navigation bar, a list labeled Fruits in edit mode. The list contains four members, each showing a red circle containing a white dash to the left of the item, and an icon composed of three horizontal lines to the right of the item.](EditButton-1) You can also create custom views that react to changes in the edit mode state, as described in ``EditMode``.

Members (1)

init · iOS 13.0+

init

TypeScript
static init(): EditButton
Swift declaration
nonisolated init()

Creates an Edit button instance.

Skipped declarations

1 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

EditButton.body

This protocol needs associated types that cannot yet cross the bridge.

All SwiftUI types →