Status Bar turning completely black when using clipsToBounds = YES in iOS8. How do I change this? - cocoa-touch

I'm setting my NavigationBar's translucent property to NO via the UINavigationBar appearance proxy in my AppDelegate.
Then, to get rid of the 1 pixel-height separator between UINavigationBar and my view's below it, in my ViewController, I'm setting self.navigationcontroller.navigationbar.clipsToBounds = YES;.
This is to remove the separator and achieve an effect similar to this...
There's an additional view with Dates underneath the UINavigationBar.
However, when I begin to use clipsToBounds = YES, my status bar goes completely black. I don't want this. I want it to be 'blue', just like it is in the photo for this CBS Sports app.
How can I change the color of the status bar, or why is my color from the navigation bar no longer extending up to the status bar? [Also, I'm using an embedded NavigationController, not one that I dragged out onto the view]

Do not set the clipsToBounds property to YES. The way extended bars work is the layer is drawn beyond its bounds until under the status bar.
You have two options here. One is to remove the separator using runtime trickery, which I have explained how to do in this answer.
Since your case does not involve translucent navigation bar, it will be much simpler. What you want to set is shadowImage to be empty like so:
self.navigationController.navigationBar.shadowImage = [UIImage new];
But you'll notice this does not work right away. Documentation mentions that this will not work until a background image is not set using one of the setBackgroundImage: methods. Since your bar is not translucent and has a single color, you can create a 1x1px wide image with the color, and set it as the background image.

A problem here is that when you set clipsToBounds to true, you lose the top of the status bar. What I do, therefore, is just the opposite of what you're doing - I make the navigation bar absolutely transparent:
self.navbar.backgroundColor = UIColor.clearColor()
self.navbar.translucent = true
self.navbar.setBackgroundImage(UIImage(), forBarMetrics:.Default)
self.navbar.clipsToBounds = true
Now we are just seeing right through the navigation bar to whatever is behind it. So you can have whole top area of your view controller's view be blue, and you just see it.

Related

get navigation bar color to give it to status bar color on iOS 5

i'm new here and i actually started learning recently and i'm making my first Theos tweak (i made some with flex) and as i said in the title i'm looking for a way to get nav bar color or a color from part of the screen and apply it as the status bar background color
You're going to need to write a function to detect your targetPixelColor as a UIColor, and then apply that color to the status bar within viewWillAppear using something like
-(void)viewWillAppear:(BOOL)animated{
[self.navigationController.navigationBar setBarTintColor:targetPixelColor];
}
you should add just blow code in view didLoad.
[Example is here]I added light Gary color.you could add your own choice colour.
self.navigationController?.navigationBar.barTintColor = UIColor.lightGray

UIProgressView: modify height for track line

Currently I'm able to customize my progress bar modifying the whole height, in this way:
let transformScale = CGAffineTransformMakeScale(1.0, newProgressbarHeight)
self.progressBar.transform = transformScale
There is a way to modify the height of track in order to obtain a progress bar like this?
As a workaround I was pondering of put a gray view under the progress bar track tint color to clear color.
Any ideas?
iOS 5 or later, UIProgressView could set its FrontProgress Image(Green Fat)
And its Background Image(Gray Slim).
You could set Two different picture to simulate this effect.
Front Image property: progressImage.
Background Image property: trackImage.
Or,
If you only like Pure Color to avoid wasting any resource, I think the method below will fit your demand.
1.Create two UIProgressView.Fat and Slim, Front and Behind.
2.Set the Front One's trackTintColor [UIColor clearColor].
The code and effect in simulator
I hope these could help you. Good Luck!

Remove UITabBar horizontal separator in iOS7

I want to remove the horizontal separator line between a UITabBar and the rest of the screen. I'm asking the same question as this guy but updated for iOS7.
Setting the background image of my UITabBar doesn't alleviate the problem, nor does setting the background image of the [UITabBar appearance] object.
Is this still possible in iOS7? If so, how?
You could also hide shadow line using this code:
[self.tabBar setValue:#(YES) forKeyPath:#"_hidesShadow"];
Swift
self.tabBar.setValue(true, forKey: "_hidesShadow")
The answer to this is pretty much the same as removing the separator of a navigation bar or a toolbar.
Officially, this is only possible by setting the shadowImage to an empty image. However, a closer look at the documentation, we see that:
For a custom shadow image to be shown, a custom background image must
also be set using the backgroundImage property. If the default
background image is used, then the default shadow image will be used
regardless of the value of this property.
By using a custom background image, you would lose the blurred background translucency.
The separator is a UIImageView that is a subview of the tab bar. You can find it in the tab bar's hierarchy and set it to hidden.
This solution uses a transparent image, so it is more preferable.
Swift
tabBar.shadowImage = UIImage()
Objective-C
tabBar.shadowImage = UIImage.new;

Detect when an added subview's frame's origin is behind the status bar

I am adding subviews to the top of my view controllers, setting the added frame's origin's y to 0
aView.frame.origin.y = 0.0;
On one instance, the view appeared behind the status bar. This can be corrected easily by setting origin.y = 20.0;
Regardless of what the cause may be, how can I detect if I need to set it to 20.0 or not? In other words, how can I find out if the top of the page is behind the status bar or not?
You can peek into window.screen.applicationFrame to see coordinates, and at UIApplication's statusBarOrientation and statusBarHidden properties. But conditionally setting your frame top to 0 or 20 isn't really the solution - you want your frames to be set up so that it does the right thing without you having to change it. 0,0 should always be the top-left visible corner of your view.
If you used the view-based application template when you created your project, nearly everything should be set up correctly - just make sure that you specify a Gray or Black status bar in your XIB.
For programmatically created view controllers that you add directly to the Window, you might need:
myViewController.frame = window.screen.applicationFrame;

Backgrounds for UInavigationBar and UIPickerView

I understand that when you create a navigation controller it comes with a navigation bar, you are only able to select three backgrounds for this (example: translucent black etc). I've seen applications that have other colors like green with the "translucent black" type feature. Are they simply creating their own background view's and setting it for the UINavigationBar? how do they get this "translucent" effect too? like the whole view is not a single color, but the top is like a lilttle transparent and the bottom a different color. Similar to the UIPickerView that has a nice design in the background.
How can I do this? design the graphs with a graphic design program? or simply use quartz (gradients, etc) on views to get this?
Thank you!
You can change the color by changing the tintColor property of the UINavigationBar
myBar.tintColor = [UIColor greenColor];