All of the asked situations are now supported in iOS 15
Destructive: (works from iOS 15)
Set .destructive
as the role
argument of the button:
Button(role: .destructive) { // ?? This argument
// delete something
} label: {
Label("Delete", systemImage: "trash")
}
![Delete Demo](https://i.stack.imgur.com/xu5cM.png)
Disabled: (works from iOS 14.2)
Add .disabled
modifier to the button.
Button {
// call someone
} label: {
Label("Call", systemImage: "phone")
}.disabled(true) // ?? This modifier
![Disabled Demo](https://i.stack.imgur.com/Inw5O.png)
Divider: (works from iOS 14)
Use a Divider()
view directly.
![Divider Demo](https://i.stack.imgur.com/Kz0LH.png)
Full Demo:
?? Remember! Do not use image
instead of systemImage
for showing an SFSymbol on the button!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…