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 ProgressView 组件。
Expo UI ProgressView 与官方 SwiftUI ProgressView API 保持一致,并支持通过 progressViewStyle 修饰符设置样式。


安装
If you are installing this in an existing React Native app, make sure to install expo in your project.
用法
注意: 使用
linear样式(确定性进度的默认样式)时,ProgressView是一个可变宽度组件,会扩展以填充可用的水平空间。在Host上使用matchContents时,应在ProgressView上应用frame修饰符,为其指定明确的宽度。或者,使用style为Host指定明确的尺寸(例如,style={{ width: 300 }}或style={{ flex: 1 }})。circular样式和不确定性加载指示器大小固定,可以与matchContents一起使用。
不确定性进度
未提供 value 时,进度视图会显示不确定性指示器(spinner)。
确定性进度
提供一个介于 0 和 1 之间的 value,以显示确定性进度。
进度视图样式
使用 progressViewStyle 修饰符更改进度视图的外观。可用样式包括:automatic、linear 和 circular。
带标签
你可以将自定义组件作为 children 传入,为进度视图提供标签。
着色的进度视图
使用 tint 修饰符更改进度视图的颜色。
基于计时器的进度
使用 timerInterval 属性创建一个会在指定时间范围内自动播放动画的进度视图。这适用于显示倒计时或定时操作。
注意: 基于计时器的进度仅适用于 iOS 16+ 和 tvOS 16+。
API
import { ProgressView } from '@expo/ui/swift-ui';
Component
Type: React.Element<ProgressViewProps>
Renders a SwiftUI ProgressView component.
boolean • Default: trueA Boolean value that determines whether the view empties or fills as time passes. If true, which is the default, the view empties.
ClosedRangeDateThe lower and upper bounds for automatic timer progress.
unionThe current progress value. A value between 0 and 1.
When undefined, the progress view displays an indeterminate indicator.
Acceptable values are: number | null