skip to Main Content

Update to Swift 6 iOS 18 and .sheet is now presented as small compared to previous versions on the iPad. I attempted to fix with the modifier .presentationDetents([.large], selection: $selectedDetent) to set the sheet size .large, but it didn’t work. I’m wondering if there’s an easy way to have the sheets display how they use to.

Notice the left is Swift 6 on iOS 17, while the right screenshot is Swift6 on iOS 18.

enter image description here

2

Answers


  1. Chosen as BEST ANSWER

    Discovered I can just set a .frame within the .sheet and manually set the size to 85% of the screen size produces similar results as the old sheet.

    .sheet(isPresented: $Open) {
        VStack{
            Text("test")
        }
        .frame(width: UIScreen.main.bounds.size.width * 0.85, height: UIScreen.main.bounds.size.height * 0.85)
    }
    

  2. Use presentationSizing to set the size of the sheet. Sheets before iOS 18 seem to be .page by default, so you can use that.

    .sheet(isPresented: $isPresented) {
        Text("Something")
            .presentationSizing(.page)
    }
    

    You can also declare your own sizings:

    struct CustomSizing: PresentationSizing {
        func proposedSize(for root: PresentationSizingRoot, context: PresentationSizingContext) -> ProposedViewSize {
            .init(width: 200, height: 300)
        }
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search