现在,我正在从 UIKit 转换为 SwiftUI。在 UIKit 中,有一个原生的关闭、X 样式按钮-UIButton.ButtonType.close,如下所示:
我想在 SwiftUI 中找到与此等效的内容(如果已经内置于 SwiftUI 中)。如果苹果还没有开始构建/转换它,这是可以理解的。我在 Apple 地图应用程序中也看到了这一点,我相信它是用 SwiftUI 构建的,如下所示(在面板的右下角):
如果没有内置的按钮样式,如何为这个关闭按钮创建一个适应浅色和深色模式的视图?太感谢了!
编辑:在 UIKIt 的故事板编辑器中,这是我正在寻找的内容:
我已经研究这个问题近半天了。我正在尝试使用 Flutter 的 SharedPreferences 包将键/值存储在应用程序的存储中。当我通过 新建 SharedPreferences 时await SharedPreferences.getInstance(),它会正确构建并运行,但是当应用程序到达该代码行时,它会崩溃并出现以下错误:
MissingPluginException (MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences))
我找到了其他 Stackoverflow 帖子,但它们没有帮助解决这个问题:
通过所有这些,我尝试了以下方法:
flutter pub getio.flutter.plugins.sharedpreferences.SharedPreferencesPlugin.registerWith(registry.registrarFor("io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin"));SharedPreferencesIOS.registerWith();flutter clean && flutter pub getSharedPreferences.setMockInitialValues({});运行/执行上述步骤后,我重新启动了编辑器(VSC)。我什至安装了带有 Flutter 扩展的 Android …