5 contextmenu ios swift swiftui
struct CardView: View {
private var name: String = "Random Name"
private var color: Color = Color.red
private var CardContent: some View {
HStack(alignment: .top) {
Text(name)
.font(.system(size: 16, weight: .medium, design: .rounded))
.frame(width: 110, height: 80, alignment: .top)
}
.padding(.top, 20)
.frame(width: 200, height: 190, alignment: .top)
.background(color)
.clipShape(RoundedRectangle(cornerRadius: 30, style: .continuous))
}
var body: some View {
CardContent
.contentShape(RoundedRectangle(cornerRadius: 30, style: .continuous))
.contextMenu {
Button(action:{}){
HStack {
Image(systemName: "trash")
.foregroundColor(Color.red)
Text("Delete")
}
}
}
.shadow(color: color.opacity(0.5), radius: 10, x: 10, y: 10)
}
}
Run Code Online (Sandbox Code Playgroud)
当我长按时,视图被错误地剪切:
]
另外,为什么垃圾桶图像不是红色的?
这是一个ContextMexu怪癖吗?
| 归档时间: |
|
| 查看次数: |
609 次 |
| 最近记录: |