This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
This is documentation for the next SDK version. For up-to-date documentation, see the latest version (SDK 57).
弹出框
用于在浮动覆盖层中显示内容的 SwiftUI 弹出框组件。
Expo UI Popover 与官方 SwiftUI Popover API 保持一致,并提供了一种方式,可在锚定到触发元素的浮动覆盖层中展示内容。


安装
If you are installing this in an existing React Native app, make sure to install expo in your project.
用法
基础 popover
附着锚点
attachmentAnchor 属性控制 popover 连接到触发元素的位置。可用选项有:center、leading、trailing、top 和 bottom。
箭头边缘
arrowEdge 属性控制 popover 的哪一侧显示箭头。可用选项有:none、leading、trailing、top 和 bottom。
使用 React Native 内容
你可以使用 RNHostView 将 React Native 组件嵌入到 popover 内容中。
API
import { Popover } from '@expo/ui/swift-ui';
Component
Type: React.Element<PopoverViewProps>
Props
string • Default: 'none'The edge of the attachmentAnchor that defines the location of the popover's arrow. The default is none, which results in the system allowing any arrow edge.
Acceptable values are: 'top' | 'none' | 'bottom' | 'leading' | 'trailing'
stringThe positioning anchor that defines the attachment point of the popover.
Acceptable values are: 'center' | 'top' | 'bottom' | 'leading' | 'trailing'
ReactNode(isPresented: boolean) => voidA callback that is called when the isPresented state changes.