This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
SwiftUI
使用 @expo/ui 构建原生 iOS 界面的 SwiftUI 组件。
@expo/ui/swift-ui 中的 SwiftUI 组件允许你从 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 组件和修饰符。

了解如何使用全新的 Expo UI 在你的 React Native 应用中构建真实的 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"。