How do I extend the scrollview top under a navigation bar in iOS 12?

617 Views Asked by At

I have a UIScrollView under a navigationbar in a detail viewcontroller.

The viewcontroller settings are the following:

enter image description here

The scrollview is pinned to the Safe Area (trailing, leading, bottom, top = 0).

enter image description here

I want to put the entire scrollview below/under the navigationbar, so that, if I make the navigationbar transparent, I can see the scrollview pinned to the top border of the device (while, at the moment, the scrollview area top corresponds to the bottom border of the navigationbar). The navigationbar should cover part of my scrollview.

I tried adautomaticallyAdjustsScrollViewInsets, contentInsetAdjustmentBehavior, and other similar solutions but nothing seemed to work.

Finally, I noticed if I replace the safe area top constraint with a superview constraint I get the expected result but I’m here to ask: is this the way to go? Is it safe? Are there any possibile drawbacks?

0

There are 0 best solutions below