disabled(_:)
Adds a condition that controls whether users can interact with this view.
Declaration
nonisolated func disabled(_ disabled: Bool) -> some View
Parameters
- disabled:
A Boolean value that determines whether users can interact with this view.
Return Value
A view that controls whether users can interact with this view.
Discussion
The higher views in a view hierarchy can override the value you set on this view. In the following example, the button isn’t interactive because the outer disabled(_:) modifier overrides the inner one:
HStack {
Button(Text("Press")) {}
.disabled(false)
}
.disabled(true)