Structure¶
EditButton¶
A button that toggles the edit mode for the current edit scope.¶
Declaration¶
struct EditButton : View
Overview¶
An EditButton toggles the EditMode (passed via editMode) for content within a container that supports EditMode.active. For example, an EditButton placed inside the toolbar of a NavigationView enables the editing of a List:
struct ExampleView: View {
@State var fruits = ["🍌", "🍏", "🍑"]
var body: some View {
NavigationView {
List {
ForEach(fruits, id: \.self) { fruit in
Text(fruit)
}
.onDelete { offsets in
fruits.remove(atOffsets: offsets)
}
}
.toolbar {
EditButton()
}
}
}
}

Editing a List using EditButton¶
An EditButton placed in the navigation bar of a NavigationView with a List in it can be used to provide an edit button for the List.
struct ExampleView: View {
@State var fruits = ["🍌", "🍏", "🍑"]
var body: some View {
NavigationView {
List {
ForEach(fruits, id: \.self) { fruit in
Text(fruit)
}
.onDelete { offets in
fruits.remove(atOffsets: offets)
}
}
.toolbar {
EditButton()
}
}
}
}

The title and appearance of an EditButton is determined by the system and cannot be overriden.
Availability¶
iOS 13.0+
Topics¶
Type Alias¶
Body The type of view representing the body of this view.
Initializer¶
init() Creates an edit button.
Instance Property¶
body The content and behavior of the view.