SwiftUI Sheet&fullScreenCover 合集

Custom Sheet

参考:

1
2
3
4
5
6
7
8
.presentationBackground(.thinMaterial)	// 模糊效果
.presentationBackground(.yellow) // 设置颜色
.presentationCornerRadius(8) // 圆角
// When it first appears, the bottom sheet is displayed in medium size. You can expand it to large size by dragging the sheet.
.presentationDetents([.medium, .large])
// supports 4 different sizes including: around 10% of the screen height;a fixed height of 200 points;the standard Medium and Large sizes
.presentationDetents([.fraction(0.1), .height(200), .medium, .large])
.presentationDragIndicator(.hidden) // 隐藏指示器

dismiss()

在 sheet 和 fullScreenCover 中都可以使用

1
2
3
4
5
6
@Environment(\.presentationMode) var presentationMode
// Use: presentationMode.wrappedValue.dismiss()
// 该方法在 iOS 15.0 后被 dismiss() 替代

@Environment(\.dismiss) var dismiss
// Use: dismiss()

SwiftUI Sheet&fullScreenCover 合集
https://wonderhoi.com/2024/10/23/SwiftUI-Sheet-fullScreenCover-合集/
作者
wonderhoi
发布于
2024年10月23日
许可协议