Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to allow UIView lie under status bar in iOS 10?

How to allow UIView lie under status bar like on the picture below?

enter image description here

like image 531
Oleh Liskovych Avatar asked Aug 11 '17 17:08

Oleh Liskovych


2 Answers

Originally answered here.

If you're using Safe Area Layout Guides you can do this completely in Interface Builder.

enter image description here

Pin the view you want under the status bar to the main view using the Top Space to Container Margin constraint instead of Top Space to Safe Area constraint.

Then on the Size Inspector for the main view, uncheck Safe Area Relative Margins.

enter image description here

like image 93
NSExceptional Avatar answered Nov 11 '22 02:11

NSExceptional


Just make sure that you've set your top space constraint equals 0 to your superview, not to the Bottom Layout Guide in the Storyboard.

In order to make status bar style like in the screenshot (white text, transparent background) you may want to set it's style to .lightContent.

like image 29
Pavel Vavilov Avatar answered Nov 11 '22 02:11

Pavel Vavilov