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 组件允许你使用 SwiftUI 从 React Native 构建完全原生的 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="Save changes" /> </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"。