隐藏基于操作系统的按钮

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

但是,我希望隐藏一个按钮,或者如果它在Mac上运行,则至少要禁用该按钮,但是如果在iPad或iPhone上运行,则允许将其启用。

有什么建议吗?

iseehr 回答:隐藏基于操作系统的按钮

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

#if targetEnvironment(macCatalyst)
    print("Disable or hide your button")
#elseif os(watchOS)
    print("for watchOS")
#else
    print("enable your button")
#endif
本文链接:https://www.f2er.com/3031978.html

大家都在问