-
I have an issue in regards to safeAreas specifically with the notch on iPhones. We don't use any storyboards or visual layout tech Xcode offers. All our layout is done in code and it works great for sims and real devices. One issue we are having with snapshots is that it does not respect the window safeAreaInset property which is set for every device. We ve code to align a logo to top of the screen. That is of cause different from device to device.
The test renders fine but our header is glued to top of the frame where it should sit further down due to the notch. So for some reason the I looked into the code and I can say that
So I guess UIApplication.shared.mainKeyWindow (what I use to get the inset for my constraints) is zero because its the So it is not the correct |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
After looking at the code a bit more, its very clear that |
Beta Was this translation helpful? Give feedback.
-
in order to layout my view components with the correct safeareas I could use the views window property. There is one catch though. The |
Beta Was this translation helpful? Give feedback.
-
I have opted to pass in the the |
Beta Was this translation helpful? Give feedback.
I have opted to pass in the the
Window
safe areas to the controller during tests, and let it layout normally when the property is nil. Its very hacky bit it works for me now.