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

- 69,473
- 35
- 181
- 253

- 991
- 3
- 13
- 31
-
try adding top = 0 to masterview. – Ivan Koop Aug 11 '17 at 17:45
-
I am not sure I understand what you mean – Oleh Liskovych Aug 11 '17 at 18:22
3 Answers
Originally answered here.
If you're using Safe Area Layout Guides you can do this completely in Interface Builder.
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.

- 1,368
- 15
- 12
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
.

- 588
- 3
- 8
You can set the status bar style to light content.
1. Add this key-val to your .Plist.
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
2. In your App Delegate class, add the following to didFinishLaunch method.
UIApplication.shared.statusBarStyle = .lightContent
Here are the relevant link.

- 2,049
- 21
- 32
-
-
@user3400881 According your question and the image you posted, the status bar can either remain shown or is completely hidden. You could set the style to light to get an effect like shown in your image. Otherwise, set it to any colour you want. By changing the style to .light, you will achieve the desired effect. You could also explore other option it has like .default – Umar Farooque Aug 11 '17 at 18:46
-
-
Setting color for status bar background is not what I am seeking for. I'll try to find another solution. But thank you for your effort. – Oleh Liskovych Aug 11 '17 at 18:56
-
Setting the style to LightContent would make the status bar transparent and whatever background colour your view has would be displayed with text appearing in white. Do try the second approach before exploring further. – Umar Farooque Aug 11 '17 at 18:59
-
I use this line in AppDelegate which do, I guess, the same UIApplication.shared.statusBarStyle = .lightContent . – Oleh Liskovych Aug 11 '17 at 19:08
-
Also when I try your code I get this error: Method does not override any method from its superclass. I think it is out of date. Look at the first letter of enum case. It's capital, which means it is written on Swift 2. – Oleh Liskovych Aug 11 '17 at 19:10
-
It does make text in status bar white, but status bar is not transperant. It's white – Oleh Liskovych Aug 11 '17 at 19:27
-
-
Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/151748/discussion-between-umar-farooque-and-user3400881). – Umar Farooque Aug 11 '17 at 19:29
-
maybe you can add a screenshot of your view .. how it looks in storyboard and on simulator when it runs – Umar Farooque Aug 11 '17 at 19:30
-
I cant attach screenshot to the comment unfortunattely. Background colour of my view has opacity 0% – Oleh Liskovych Aug 11 '17 at 19:33