1 year ago

#332287

test-img

Victor

Swift - Layout problem with scrollview and safe area

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
    }

swift

layout

uiscrollview

xcode-storyboard

safearealayoutguide

0 Answers

Your Answer

Accepted video resources