-1

I am pretty new to SwiftUI programming and ran into the following problem that I cannot find an answer to.

I want to open a sheet modal from my Main View and want to present a simple View with an Rect on it (for testing purposes).

 .sheet(isPresented: $api.showDrawing) {
      
      DrawingViewView()
 }

My DrawingViewView looks like:

    struct DrawingViewView: View {
      var body: some View {
        Rectangle()
          .fill(Color.red)
          .frame(width: 1500, height: 1000)
       }
     }

No matter how big I make the Rect it is never shown bigger than:

enter image description here

Is there a way to make the sheet bigger in width?

EDIT: I also thought of using a fullScreenCover, but if I open a PKCanvasView in a fullScreenCover pencilKit is acting weird. The lines I draw do not correspond with the pencilInput

EDIT: Apperently the problem is the horizontal orientation. If I turn my iPad vertical I have no problems at all!

Thanks a lot!

Jakob

jakob witsch
  • 157
  • 1
  • 1
  • 12
  • Likely not with a `sheet` you will have to use a `presentationController` from UIKit. [Here](https://stackoverflow.com/questions/56700752/swiftui-half-modal/67994666#67994666) is a starting point. It isn't what you are looking for but a start. – lorem ipsum Nov 24 '21 at 14:04

1 Answers1

0

I think this is the easiest way to do it.

import SwiftUI

struct FullScreenModalView: View {
    @Environment(\.presentationMode) var presentationMode

    var body: some View {
        ZStack {
            Color.red.edgesIgnoringSafeArea(.all)
            Button("Dismiss Modal") {
                presentationMode.wrappedValue.dismiss()
            }
        }
    }
}

struct ContentView: View {
    @State private var isPresented = false

    var body: some View {
        Button("Present!") {
            isPresented.toggle()
        }
        .fullScreenCover(isPresented: $isPresented, content: FullScreenModalView.init)
    }
}

struct ex_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

Hope is what you expected!

  • Thanks for the quick reply! I already thought of using a fullScreenCover, but pencilKit is behaving really weird on it. If I open my PKCanvasView in a fullScreenCover my pencil input does not correspond with the lines I draw. I have no idea why this behavior occurs ... – jakob witsch Nov 24 '21 at 15:03
  • EDIT: Apperently the problem is the horizontal orientation. If I turn my iPad vertical I have no problems at all! – jakob witsch Nov 24 '21 at 15:11
  • 1
    If you need to draw with the pencil maybe it'll be better if you use UIKit the most you can, because SwiftUI still needs improvements. – Alexander Thoren Nov 24 '21 at 15:37