How to make ZStack coordinates same as the iOS Coordinate system?

Viewed 88

I have a ZStack within my view with many other shapes where users can draw. I'd like for the coordinate points within the ZStack to be the same as if the users were drawing within the full iOS window (reference of the grid here: https://developer.apple.com/library/archive/documentation/General/Conceptual/Devpedia-CocoaApp/CoordinateSystem.html).

Right now when a user draws within a shape the coordinates start at the top right corner of the shape meaning the actual coordinates within the full window can be 50,50 or something like that but in the ZStack it'll say 0,0.

How do you get the ZStack and all relevant Shape within it to render the same points as it would drawing in the full iOS window?

edit: adding image for clarity

enter image description here

1 Answers

I assume you wanted this

ZStack {
    Color.clear     // background

    // your content here

}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.ignoresSafeArea()
Related