.presentationDetents([.fraction( 1), .height(400), .medium, .large])
Run Code Online (Sandbox Code Playgroud)
使用 .cornerRadius(INT) 在这里不起作用,似乎无法设置角半径。
在 iOS 16.4 之前,无法在 SwiftUI 中更改工作表的圆角半径。iOS 16.4 添加了presentationCornerRadius:修饰符:https://developer.apple.com/documentation/swiftui/view/presentationcornerradius(_:)
iOS 16.4 SDK 包含在 Xcode 14.3 中。
这是从 Apple 关于新修饰符的文档中复制的示例代码:
struct ContentView: View {
@State private var showSettings = false
var body: some View {
Button("View Settings") {
showSettings = true
}
.sheet(isPresented: $showSettings) {
SettingsView()
.presentationDetents([.medium, .large])
.presentationCornerRadius(21)
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2708 次 |
| 最近记录: |