支持 iOS 12 及更高版本的小部件

时间:2021-02-16 07:08:46

标签: ios swift xcode widget today-extension

我的应用需要支持 iOS 12 及更高版本的小部件。我创建了一个运行良好的 Today 扩展小部件。但是现在对于 iOS 14,我想显示新的小部件。我知道如何在 iOS 14 中创建小部件,但需要知道如何在这些小部件之间切换,以支持向后兼容到 iOS 12 并使用适用于 iOS 14 及更高版本的新小部件。

基本上我需要这样的东西。但不知道该怎么做。

if #available(iOS 14.0, *) {
    // use the new widget created with widget extension
} else {
    // use the old widget created with today extension
}

感谢任何帮助。

0 个答案:

没有答案
相关问题