Extending the UIViewController view without a navigation bar in the status bar

There is no navigation bar in my view, but I want to display the content in the status bar. I checked the edge extension under the upper bars, under the opaque bars in my view controller, the view I want to display in the status bar has 0 vertical limits on the distance to the top layout guide, but still, here's what I get:

enter image description here

The status bar has a 20px solid white background, which I don't want. I want my view to overlap in the status bar, just like the layout below:

enter image description here

How can I do this without having a visible navigation bar (I still have this, since my view is guaranteed to be inside the navigation controller, but it will never be visible, since I have many of the specially designed sections, including the upper bars)?

+6
source share
3 answers

After several tens of pages for several hours, I found the answer:

for (NSLayoutConstraint *constraint in self.view.constraints) { if((constraint.firstItem == self.topLayoutGuide && constraint.secondItem == self.view) || (constraint.secondItem == self.topLayoutGuide && constraint.firstItem == self.view)) { constraint.constant = -20; } } 

For those who were wondering, I did not use a specific answer, but the solution that was deduced from this question was: iOS7 - viewing in the status bar - edgeForExtendedLayout does not work .

+5
source

On the view controller or parent view controller, you must set automaticallyAdjustsScrollViewInsets to NO . The previous answer is a bit hacked as the structure provides a property that controls this behavior.

+1
source

If you use safe area planning guides, you can do this completely in the Builder interface.

enter image description here

Highlight the view you want in the status bar to the main view using the โ€œ Top Space to Safe Area restriction of the โ€œ Top Space to Container Margin โ€ restriction instead of the โ€œ Top Space to Safe Area โ€ restriction.

Then, in the "Size inspector" window in the main window, uncheck the "Relative margin of the safe zone" box.

enter image description here

0
source

Source: https://habr.com/ru/post/1212812/


All Articles