组
SwiftUI 的 Group 组件用于对视图进行分组而不影响布局。
iOS
tvOS
Bundled version:
~55.0.2
Expo UI 组匹配官方的 SwiftUI Group API,可以将视图组合在一起,而不会引入额外的布局结构。
🌐 Expo UI Group matches the official SwiftUI Group API and groups views together without introducing additional layout structure.
安装
🌐 Installation
Terminal
- npx expo install @expo/uiIf you are installing this in an existing React Native app, make sure to install expo in your project.
用法
🌐 Usage
基础组
🌐 Basic group
组对于一次性将修饰符应用到多个视图或在不影响布局的情况下组织视图非常有用。
🌐 Groups are useful for applying modifiers to multiple views at once or organizing views without affecting layout.
BasicGroupExample.tsx
import { Host, Group, Text } from '@expo/ui/swift-ui'; import { foregroundStyle } from '@expo/ui/swift-ui/modifiers'; export default function BasicGroupExample() { return ( <Host matchContents> <Group modifiers={[foregroundStyle({ color: 'blue' })]}> <Text>First item</Text> <Text>Second item</Text> <Text>Third item</Text> </Group> </Host> ); }
应用接口
🌐 API
import { Group } from '@expo/ui/swift-ui';
Component
Type: React.Element<GroupProps>
Type:
ReactNode