【问题标题】:SwifUI contextMenu Cell previewSwiftUI 上下文菜单单元格预览
【发布时间】:2022-12-28 22:37:04
【问题描述】:

我正在 swiftUI 中制作一个应用程序,我想看看是否有人知道如何使用 contextMenu 实现以下效果: 我想要的是当调用 contextMenu 函数时

CellView().contextMenu { }

显示另一个视图或预览,如 Twitter 示例中所示。

谢谢

【问题讨论】:

    标签: swift swiftui


    【解决方案1】:

    你可以使用func contextMenu<M, P>(menuItems: () -> M, preview: () -> P) -> some View

    .contextMenu(menuItems: {
        Text("your menu items")
    }, preview: {
        Text("preview")
    })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-05-24
      • 2020-05-23
      • 1970-01-01
      • 2020-08-14
      • 1970-01-01
      • 1970-01-01
      • 2021-12-28
      • 1970-01-01
      相关资源
      最近更新 更多