0

As you can see from the video, when the code is built and ran, the Red View is 0px from the top edge. But after scrolling down and tapping the status bar to return to the top, there is a gap between the top of the screen and Red View (i.e. the black area).

GIF of Simulator

What can I do to resolve the issue if the intended behaviour is for the Red View to be 0px from the top of display when the user scroll up to the very top?

  • 1
    Check your Top constraint whether it's with `Safe Area` or `Super View` – Amir Khan Mar 31 '19 at 15:55
  • The intended behaviour might not be achieved in case there is lesser content below the red view in the scroll view. Show your storyboard for more details here. – schinj Apr 01 '19 at 08:33

1 Answers1

0

Try setting a minus value for the scrollviews content inset:

scrollView.contentInset = UIEdgeInsets(top: -40, left: 0, bottom: 0, right: 0)

Your could also check the safe area.

This is a normal behavior in iOS. iOS will try to leave room for the status bar if you are using safe areas.

Pointblaster
  • 504
  • 3
  • 18