SwiftUI

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

iOS
tvOS
Bundled version:
~55.0.2

重要 此库当前处于测试版,可能会发生重大更改。 它在 Expo Go 应用中不可用——请使用 开发版本 进行尝试。

@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

Terminal
npx expo install @expo/ui

If you are installing this in an existing React Native app, make sure to install expo in your project.

用法

🌐 Usage

使用 @expo/ui/swift-ui 的组件时,需要将其封装在 Host 组件中。Host 是 SwiftUI 视图的容器。

🌐 Using a component from @expo/ui/swift-ui requires wrapping it in a Host component. The Host is a container for SwiftUI views.

import { Host, Button } from '@expo/ui/swift-ui'; export function SaveButton() { return ( <Host style={{ flex: 1 }}> <Button label="Save changes" /> </Host> ); }

欲了解更多信息,请参见以下资源:

🌐 For more information, see the following resources:

Expo UI Swift UI 指南

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

使用 SwiftUI 扩展

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

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

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