This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
This is documentation for the next SDK version. For up-to-date documentation, see the latest version (SDK 57).
SwiftUI
使用 @expo/ui 构建原生 iOS 界面的 SwiftUI 组件。
SwiftUI 组件位于 @expo/ui/swift-ui 中,允许你使用 React Native 中的 SwiftUI 构建完全原生的 iOS 界面。
安装
If you are installing this in an existing React Native app, make sure to install expo in your project.
用法
Expo UI 提供了多个 SwiftUI 组件。你可以从 @expo/ui/swift-ui 导入这些组件,并在应用中使用。不过,要从 React Native(UIKit)跨越到 SwiftUI,你需要使用 Host 组件。 Host 是 SwiftUI 视图的容器。你可以把它想象成 DOM 中的 <svg>,或 react-native-skia 中的 <Canvas>。在底层,它使用 UIHostingController 在 UIKit 中渲染 SwiftUI 视图。
import { Host, Button } from '@expo/ui/swift-ui'; export function SaveButton() { return ( <Host style={{ flex: 1 }}> <Button label="保存更改" /> </Host> ); }
创建可与 Expo UI 集成的自定义 SwiftUI 组件和修饰符。

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


































































示例
修饰符
SwiftUI 修饰符可以自定义 SwiftUI 组件的外观和行为。Expo UI 也为 SwiftUI 组件提供了修饰符。你可以从 @expo/ui/swift-ui/modifiers 导入修饰符,并将其作为数组传递给 modifiers 属性。在以下示例中, expo-mesh-gradient 和 glassEffect 修饰符组合在一起,创建出 Liquid Glass 文本。
glassEffect修饰符需要 Xcode 26+ 和 iOS 26+。
iOS 设置应用
结合使用 Expo UI 组件和修饰符,你可以构建类似 iOS 设置应用的界面。
次要文本样式
使用 foregroundStyle 应用分层样式,使文本显示得更浅、更柔和。
带图标的滑块
亮度或音量控制中常见的一种模式是在 Slider 两侧放置图标。
多行列表项
对于包含标题和副标题的列表项,使用 VStack 并设置 alignment="leading"。