多平台(iOS,macOS)SwiftUI底页抽屉
多平台(iOS,macOS)SwiftUI底页抽屉
特征
- 使用您自己的规格自定义组件
- 支持 iOS 和 macOS
- 深色和浅色方案支持
- 观察工作表位置的变化,如果你需要对它做出反应
- 响应任何尺寸变化 当窗口大小更改时,这对于 macOS 很重要
创造
将组件放入绝对坐标空间(如 ZStack 或 GeometryReader)中,只需传递一个内容即可从工作表抽屉开始。
BottomSheet(
content: ContentView()
)
自选
shift
– 纸张抽屉的可见高度topIndentation
– Space from the very top to the max height drawer can reachshowDragButton
– Hide or show drag buttondraggerHeight
– Space sensitive for draggingdragThresholdToAct
– Dragging length after which trigger move to the next level depending on the direction of movingdoAnimation
– Animate move
Observing sheet positions
Observe sheet positions on change if you need to react on it in the external context of the component. For example to update layout of the drawer content according a new size of the height. Possition BottomSheetPosision is passed with height of the sheet. height – is enum associated with value of type CGFloat
@State private var position: BottomSheetPosision
BottomSheet(
content: SheetCintentView(position: $position)
)
.onPreferenceChange(BottomSheetPosisionKey.self) {
position = $0
}
Position | Description |
---|---|
up(CGFloat) | At the top |
middle(CGFloat) | At the middle |
down(CGFloat) | At the bottom |
SwiftUI example of using package
Folow the link to get the example exposed in the video:
Documentation(API)
- You need to have Xcode 13 installed in order to have access to Documentation Compiler (DocC)
- Go to Product > Build Documentation or ⌃⇧⌘ D