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.
背景
一个 SwiftUI Background 组件,用于在另一个视图后方分层放置内容。
iOS
tvOS
Included in Expo Go
Expo UI Background 与官方 SwiftUI background 修饰符相匹配,会在视图后方绘制背景内容,并按照指定的对齐方式进行定位。基础视图保持自身大小不变。
若要使用颜色、材质或渐变填充视图,请使用
@expo/ui/swift-ui/modifiers中的background修饰符。
安装
Terminal
If you are installing this in an existing React Native app, make sure to install expo in your project.
用法
基础背景
BackgroundExample.tsx
背景对齐方式
使用 alignment 属性相对于基础视图定位背景内容。由于背景不会影响基础视图的布局,因此可以将较小的背景固定在某一条边上。
BackgroundAlignmentExample.tsx
API
import { Background } from '@expo/ui/swift-ui';
Component
Type: React.Element<BackgroundProps>