如何更改底板角半径?斯威夫特用户界面

Dev*_*dus 2 ios swift swiftui

.presentationDetents([.fraction(   1), .height(400), .medium, .large])
Run Code Online (Sandbox Code Playgroud)

使用 .cornerRadius(INT) 在这里不起作用,似乎无法设置角半径。

Geo*_*rth 9

在 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)