Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix why status bar space behind ScrollView in Xcode?

I added a scroll view to my view which is hover the status bar (I hid it). The scroll view is working fine, but when I'm scrolling to the top, I have a white space which disappears when I tap on my screen, and appears again when I scroll down then top.

I noticed that the scroll bar is not going to the top of my view, but stopped at the status bar.

Here are screenshots which show you what I mean.

Here I'm at the top of my view but the scroll bar isn't:

Here is the same view with the white status bar which appears when I scroll top again:

It disappear when I tap on my screen or scroll down.

Here are my constraints:

constraints

I think it's a problem of Layout Margin or something like that, but I don't what I should change?

I hide the status bar like that in my view controller:

override func viewWillAppear(_ animated: Bool) {
    UIApplication.shared.keyWindow?.windowLevel = UIWindowLevelStatusBar

    super.viewWillAppear(animated)
}

EDIT: Even if I comment the line which hides the status bar, I still have the same problem with my scroll view. So the problem doesn't come from how I hide it.

like image 879
cusmar Avatar asked Dec 18 '22 01:12

cusmar


1 Answers

As Sam said, I changed the content insets to "Never" on the scroll view and it works.

like image 198
cusmar Avatar answered May 07 '23 06:05

cusmar