隐藏按钮基于 OS

Hide Button based on OS

我正在为 MacOS 上的 iPad 和 运行 编写一个应用程序,到目前为止,它在迁移到 MacOS 方面运行良好。

但是,如果 运行 在 mac 上处于 运行 状态,我希望隐藏按钮或至少禁用该按钮,但如果在 运行 处于 [] 状态,则允许启用该按钮=17=] 或 iPhone.

有什么建议吗?

如果您尝试 运行 在 macCatalyst 上,则可以使用此代码

#if targetEnvironment(macCatalyst)
    print("Disable or hide your button")
#elseif os(watchOS)
    print("for watchOS")
#else
    print("enable your button")
#endif