skip to Main Content
.presentationDetents([.fraction(   1), .height(400), .medium, .large])

using .cornerRadius(INT) does not work here, there seems to be no way to set a corner radius.

2

Answers


  1. It’s not possible to change the corner radius of a sheet in SwiftUI until iOS 16.4 (which is still in beta at the time of writing). iOS 16.4 adds a presentationCornerRadius: modifier: https://developer.apple.com/documentation/swiftui/view/presentationcornerradius(_🙂

    The iOS 16.4 SDKs are included in Xcode 14.3 (also in beta at the time of writing).

    This is the sample code copied from Apple’s documentation on the new modifier:

    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)
            }
        }
    }
    
    Login or Signup to reply.
  2. If you need to support older versions of iOS, there are fully or partially custom solutions for you

    Popular packages that do not overuse the native modal dialogs implementation:

    This package was written by me and uses Apple’s private API and allows you to customize native modal dialogs:
    NativePartialSheet

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search