case active
case inactive
case transient
Availability 有効性
Technology
enum EditMode
You receive an optional binding to the edit mode state when you read the edit
environment value. The binding contains an Edit
value that indicates whether edit mode is active, and that you can use to change the mode. To learn how to read an environment value, see Environment
.
Certain built-in views automatically alter their appearance and behavior in edit mode. For example, a List
with a For
that’s configured with the on
or on
modifier provides controls to delete or move list items while in edit mode. On iOS and tvOS, lists configured for selection activate the selection interface only when edit mode is active.
You can also customize your own views to react to edit mode. The following example replaces a read-only Text
view with an editable Text
, checking for edit mode by testing the wrapped value’s is
property:
private var editMode (\.editMode)
private var name = "Maria Ruiz"
var body: some View {
Form {
if editMode?.wrappedValue.isEditing == true {
TextField("Name", text: $name)
} else {
Text(name)
}
}
.animation(nil, value: editMode?.wrappedValue)
.toolbar { // Assumes embedding this view in a NavigationView.
EditButton()
}
}
You can set the edit mode through the binding, or you can rely on an Edit
to do that for you, as the example above demonstrates. The button activates edit mode when the user taps it, and disables the mode when the user taps again.
case active
case inactive
case transient
var isEditing : Bool
static func == (EditMode , EditMode ) -> Bool
static func != (Self, Self) -> Bool
func hash(into: inout Hasher)
var hashValue : Int
enum ColorScheme
enum ColorSchemeContrast
enum UserInterfaceSizeClass