我试图在 中配置按钮contextMenu,但它不起作用。
Text("A label that have context menu")
.contextMenu {
Button(action: {
// remove it
}) {
Text("Remove")
.foregroundColor(.red) // Not working
Image(systemName: "trash")
}.disabled(true) // Not working
}
Run Code Online (Sandbox Code Playgroud)
我拥有的:
我在寻找什么:(删除和呼叫按钮)
我会创建一个UIAction类似以下的内容,UIKit但我找不到任何修饰符或无论如何将其带到SwiftUI:
let delete = UIAction(title: "Remove", image: UIImage(systemName: "trash"), attributes: .destructive) { action in
// remove it
}
Run Code Online (Sandbox Code Playgroud)