Reference version

间隔器

一个用于灵活间距的 SwiftUI Spacer 组件。

iOS
tvOS
Bundled version:
~55.0.0-beta.0

For the complete documentation index, see llms.txt. Use this Use this file to discover all available pages.

Expo UI Spacer 与官方 SwiftUI Spacer API 保持一致,并会扩展以填充栈中的可用空间。

安装

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.

用法

HStack 中的基础 Spacer

使用 Spacer 将内容推到水平栈的两端。

SpacerHStackExample.tsx
import { Host, HStack, Text, Spacer } from '@expo/ui/swift-ui'; export default function SpacerHStackExample() { return ( <Host style={{ flex: 1 }}> <HStack> <Text></Text> <Spacer /> <Text></Text> </HStack> </Host> ); }

VStack 中的基础 Spacer

使用 Spacer 将内容推到垂直栈的两端。

SpacerVStackExample.tsx
import { Host, VStack, Text, Spacer } from '@expo/ui/swift-ui'; export default function SpacerVStackExample() { return ( <Host style={{ flex: 1 }}> <VStack> <Text>顶部</Text> <Spacer /> <Text>底部</Text> </VStack> </Host> ); }

API

import { Spacer } from '@expo/ui/swift-ui';

Component

Spacer

iOS
tvOS

Type: React.Element<SpacerProps>

SpacerProps

minLength

iOS
tvOS
Optional • Type: number

The minimum length of the spacer. This is the minimum amount of space that the spacer will take up.