Reference version

SwiftUI

用于构建原生 iOS 界面的 SwiftUI 组件,使用 @expo/ui。

iOS
tvOS
Included in Expo Go
Bundled version:
~56.0.6

For the complete documentation index, see llms.txt. Use this file to discover all available pages.

@expo/ui/swift-ui 中的 SwiftUI 组件允许你使用 SwiftUI 从 React Native 构建完全原生的 iOS 界面。

安装

Terminal
npx expo install @expo/ui

If you are installing this in an existing React Native app, make sure to install expo in your project.

用法

使用 @expo/ui/swift-ui 中的组件时,需要将其包装在 Host 组件中。Host 是 SwiftUI 视图的容器。

import { Host, Button } from '@expo/ui/swift-ui'; export function SaveButton() { return ( <Host style={{ flex: 1 }}> <Button label="保存更改" /> </Host> ); }

更多信息请参阅以下资源:

Expo UI guide for Swift UI

了解 @expo/ui/swift-ui 的基础知识

使用 SwiftUI 扩展

创建可与 Expo UI 集成的自定义 SwiftUI 组件和修饰器。

Expo UI iOS Liquid Glass 教程
Expo UI iOS Liquid Glass 教程

了解如何使用新的 Expo UI 在你的 React Native 应用中构建真正的 SwiftUI 视图。