【发布时间】:2021-09-14 08:30:15
【问题描述】:
我想以与 Apple 照片应用程序相同的方式使用上下文菜单:当您长时间按下方形图像时,您会以图像的原始格式获得图像的全屏预览,并且不像网格中的正方形。但是当我使用上下文菜单时,预览的格式与显示的格式相同。
这是我的代码,在此先感谢。
struct CardView: View {
let url: URL
var body: some View {
GeometryReader { proxy in
AnimatedImage(url: url)
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: proxy.size.width, height: proxy.size.height, alignment: .center)
.cornerRadius(4)
.contextMenu(ContextMenu(menuItems: {
Button {
print("Saved \(url)")
} label: {
HStack {
Text("Save Image")
.padding(20)
Image(systemName: "square.and.arrow.down")
.resizable()
.font(.title)
}
}
}))
}
}
}
【问题讨论】:
标签: swiftui contextmenu