Change background color of viewcontroller but not top area with clock - ios

I want to make my whole ViewController grey except I want the top area where it shows CARRIER and the current time to remain white. Is the only way just to stick a View that covers everything except that area, and set it to grey, or is there some way to set the entire background to grey and only set that one strip to white

The "top area with clock" is called a status bar. That bar is transparent and is displayed as the topmost view in a window. This means that nothing can cover the status bar.
You can show, hide and change the appearance of the status bar (changing the content from Light to Dark implies that the text colour within your status bar will be either white or black) by sending the appropriate message to the [UIApplication sharedApplication] object.
Now that you know a little bit about the status bar, I can answer your question:
In order to have a different background under the status bar than on the rest of the screen, you need to add a view with the frame [[UIApplication sharedApplication] statusBarFrame]. Then you can colour the view property of the view controller differently than the view underneath the status bar.

Set your ViewController's view's background color to gray. Then add a white subview to it matching the status bar's frame.

Related

Why is there a white area where my iOS Status Bar is supposed to be

I created a new view controller and connected it up in an existing storyboard. I can see the status bar on all the preceding screens, but not on this one. There is just a white bar where it should be. I'm not doing anything to hide the status bar!
I have no idea why, but the base view of my view controller was not transparent. When I made the background color of the base view of the view controller transparent, I could see my status bar again.

iOS is it possible to have status bar that is half light and half dark

I have status bar where left part is on dark background and I have there light text content. But right part of status bar background is on the other hand white and I would like to have there black text.
Is it possible to set different colours of status bar content in left and right half. In left I have dark menu and in right I have content on white background.
I found solution but I have Split View Controller and then I can override in preferredStatusBarStyle differently in Master and Detail view controller. In general I think it will not be possible while having single view controller

iOS status bar background overlaps UIAlertController

The main view of my app is a scrollable UICollectionView embedded in a UITabBarController. I'm not using a navigation bar and when the user scrolls he sees the cells behind the status bar, because the status bar has no background.
I've used UIApplication.shared.statusBarView?.backgroundColor = .white in my AppDelegate to apply a background and to make the status bar look like desired.
This works fine, but doesn't look nice when you're presenting a UIAlertController.
The white status bar stays above the dimmed background.
Is there a better way to apply a background to the status bar or a way to keep it behind the UIAlertController background?
You can try to use a UIView with a background color at the top of your presenting UIView.
Height of status bar can come from UIApplication.shared.statusBarFrame. And update your view size when receiving UIApplication.didChangeStatusBarFrameNotification.

How make the status bar opaque on Xamarin for app without navigation bar

I have a app that only have a form with a web view. When the web view scroll (it have a white background) the content slide behind the status bar, turning it transparent (only the battery indicator is visible. The rest text of the status bar was white and now is not visible).
I need the status bar to be opaque, and the content disappear behind it.
I try setting Status bar style to default, opaque style and none work. Neither putting the background color of the view.

Clear background for status bar in iOS

How can I set the colour of the status bar to be clear. No matter what I do, it is white with some alpha.
I do not want it to disappear and I want the text to be black.
In the picture it might look like nag bar and status bar are grey but actually both are white with some blur affect or nag bar has blur affect and status bar is clear.
Here is what I get despite the clear status bar background colour
The status bar has no background since iOS 7. In other words, it's clear by default.
If you see it white, it means the underlying view is white, and you need to change that.
I was having the same problem. It ended up that my view was constrained to the top layout guide when instead it should have been constrained to the superview. Even though the view is constrained to different points it will look the same in interface builder (in my case, I think this is because I was instantiating the viewcontroller to my navigation controller in code and not displaying the navbar). See the image below.
Click on the constraints for the imageview in the view above and the difference in constraints can be seen in the size inspector.
Constraining to the superview will look like this:
This results in the simulator displaying the view like this:
Notice how the status bar is clear and overlaid on top of the imageview.
Constraining to the top layout guide will look like this:
This results in the simulator displaying the view like this:
Notice how the status bar appears white and how the imageview seems constrained to the status bar (the status bar is white text on a white background fyi).
So, in order to fix this problem, you need to change the constraint of the image view to be constrained to the superview.
You change this by selecting the constraint in this list:
Once you have the constraint selected you can change what the constraint is attached to over here:

Resources