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 界面。
🌐 The SwiftUI components in @expo/ui/swift-ui allow you to build fully native iOS interfaces using SwiftUI from React Native.
安装
🌐 Installation
If you are installing this in an existing React Native app, make sure to install expo in your project.
用法
🌐 Usage
Expo UI 有几个可用的 SwiftUI 组件。你可以通过从 @expo/ui/swift-ui 导入它们在你的应用中使用。不过,要从 React Native(UIKit)跨界到 SwiftUI,你需要使用 Host 组件。Host 是 SwiftUI 视图的容器。你可以把它想象成 DOM 中的 <svg> 或 react-native-skia 中的 <Canvas>。在底层,它使用 UIHostingController 在 UIKit 中渲染 SwiftUI 视图。
🌐 Expo UI has several SwiftUI components available. You can use them in your app by importing them from @expo/ui/swift-ui. However, to cross the boundary from React Native (UIKit) to SwiftUI, you need to use the Host component. The Host is the container for SwiftUI views. You can think of it like <svg> in the DOM or <Canvas> in react-native-skia. Under the hood, it uses UIHostingController to render SwiftUI views in UIKit.
import { Host, Button } from '@expo/ui/swift-ui'; export function SaveButton() { return ( <Host style={{ flex: 1 }}> <Button label="Save changes" /> </Host> ); }
创建与 Expo UI 集成的自定义 SwiftUI 组件和修饰符。

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


































































示例
🌐 Examples
修饰符
🌐 Modifiers
SwiftUI 修改器 可以自定义 SwiftUI 组件的外观和行为。Expo UI 也为 SwiftUI 组件提供了修改器。你可以从 @expo/ui/swift-ui/modifiers 导入修改器,并作为数组传递给 modifiers 属性。在下面的例子中,expo-mesh-gradient 和 glassEffect 修改器被组合,用来创建 Liquid Glass 文字效果。
信息
glassEffect修饰符需要 Xcode 26+ 和 iOS 26+。
iOS 设置应用
🌐 iOS Settings app
结合 Expo 的 UI 组件和修饰符,你可以做出像 iOS 设置应用一样的界面。
🌐 Combining the Expo UI components and modifiers, you can build a UI like the iOS Settings app.
次要文本样式
🌐 Secondary text styling
使用 foregroundStyle 来应用 分层样式,可以让文字看起来更轻、更微妙。
🌐 Use foregroundStyle to apply a hierarchical style, which makes text appear lighter and more subtle.
带图标的滑块
🌐 Slider with icons
亮度或音量控制的常见模式是用图标将 Slider 两侧包围。
🌐 A common pattern for brightness or volume controls is to flank a Slider with icons.
多行列表项
🌐 Multi-line list items
将 VStack 与 alignment="leading" 一起用于带有标题和副标题的列表项。
🌐 Use VStack with alignment="leading" for list items with a title and subtitle.