0

I have a problem with a scrollable layout I have two UiViewController :

One on the top with a green background (TopVC) and the other is red (the initial VC) which are perfectly scrollable

When I start the app, I have this layout problem : I see the bottom of the other VC(the green one).

enter image description here

When I start to scroll, this layout problem dissapear and I can scroll up and down without any layout problem.( as you can see the SafeAreaView covers the entire screen as expected )

Does someone know how I can fix that in order to start with a correct layout ?

Thanks

For info, the project that I have tested :(link of the github project)

enter image description here

Fixed with :

if let top
        = UIApplication.shared.windows.first?.safeAreaInsets.top
    {
        scrollView.contentInset.top = -top
    }
Victor
  • 61
  • 1
  • 13
  • 1
    It could be an automatic inset that I noticed in another question, does this answer help you in anyway: https://stackoverflow.com/a/71044943/1619193 – Shawn Frank Mar 24 '22 at 18:03
  • Yes, indeed , for perfect correction it is fixed with : if let top = UIApplication.shared.windows.first?.safeAreaInsets.top { scrollView.contentInset.top = -top } – Victor Mar 24 '22 at 18:23

0 Answers0