Reference version

This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.

SwiftUI

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

iOS
tvOS
Included in Expo Go
Recommended version:
~56.0.26

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

安装

Terminal
- npx expo install @expo/ui
- yarn expo install @expo/ui
- pnpm expo install @expo/ui
- bun 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 Swift UI 指南

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

使用 SwiftUI 扩展

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

Expo UI iOS 液态玻璃教程
Expo UI iOS 液态玻璃教程

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

可用组件