Backgrounds for UInavigationBar and UIPickerView - cocoa-touch

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];

Related

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

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.

weird UITabBar color inconsistency in iOS7

I'm using iOS 7's tintColor and barTintColor properties to color my UITabBar with this code in a subclass of UITabBarController:
[[UITabBar appearance] setBarTintColor:[UIColor colorWithRed:123/255.0 green:47/255.0 blue:85/255.0 alpha:1]];
[[UITabBar appearance] setTintColor:[UIColor colorWithRed:227/255.0 green:180/255.0 blue:204/255.0 alpha:1]];
On three screens, the color is what I want it to be (only two images illustrating this):
One one screen, the color is weirdly lighter. This screen is a UIWebView.
Then on a fourth screen, the color is SUPER-light. This screen is the only one to use a storyboard--the rest are all done programmatically.
What am I doing wrong? Do the fact that the misbehaving screens are a UIWebView and a storyboard have anything to do with why they're misbehaving? And how do I fix them? I've fiddled with the alpha of the bar but it doesn't change anything.
Thanks for your help.
You're seeing tab bar translucency...i.e. the background view is bleeding through and being blurred. If you want to disable this, you can do:
[tabBar setTranslucent:NO]
on your tab-bar.
On your top two images, its not clear to me if the underlying view controller view is edge-to-edge, i.e. your top two images should look like the fourth one since both have pink backgrounds. Anyhow, setTranslucent:NO should make them all look like the top image.
You can also uncheck "Translucent" at the Attributes Inspector:

Transparent NSWindow but with standard border and shadow [duplicate]

This question already has an answer here:
Holes in NSView or NSWindow
(1 answer)
Closed 6 years ago.
I want to have a more or less standard NSWindow with a toolbar and all that, but I want the content view to be transparent so that I can see through it. At the same time I want to keep the light gray outline of the window and also it's shadow. BUT I want to avoid the "inner" shadow I get from the toolbar inside the content view area.
What I have tried so far is just to set the window background color to a semi transparent color and also set opaque to NO. The problem is that the window border fades away with the alpha of the background itself, and the more transparency I have on the background, the more the shadow of the toolbar shows up within the content view.
Generally, the window shadow and border changes depending on the transparency of the content view, which I totally understand. But I want a behavior where it keeps the border and shadow just as if it was a completely opaque window, and then I want the content view area to be transparent.
I am not sure what I need to do conceptually to make it work. Maybe I have to draw the window border myself, maybe not. Maybe I need to draw the shadow myself, or maybe not.
Is there anyone that know how to build this? I don't need exact code details, but rather what parts I need to do custom..
I appreciate any input!
I dont't know if this is of any value for you after all this time but try:
[aWindow setOpaque:NO];
[aWindow setBackgroundColor:[NSColor clearColor]];
Subclass the NSView class, override the drawRect:(NSRect)dirtyRect method and set the color of the view as clearcolor, now set the class of your content view as the Subclass of NSView.

How to customize UISegmentedControl font color and UIToolbar gradient?

It seems Apple's UIToolbar and some of the controls you can place on it, such as UISegmentedControl, allow very limited customization. For example, we want our toolbar to looks something like this mock:
However, UIToolbar only has a single tintColor and 3 built-in barStyle values that you can apply to it, so we can't get the gradient we're after. Is there some way to set the background image like many of the other controls?
Even worse, the UISegmentedControl doesn't let you specify font or font color. It seems to enforce white 11pt Helvetica with a drop shadow, and the white is almost unreadable with the light tintColor we're using.
I'd hate to rewrite UISegmentedControl just to change the text color. But the only solution I've seen is very hacky -- it digs into the subviews of the subviews and changes properties on those -- seems likely to stop working whenever Apple feels like changing or disallowing it.
Is Apple really against us changing the text color on our segmented controls, or is there something I'm missing here?
Update: Apple finally added functions for customizing appearance in iOS 5. See jfortmann's answer.
You want to use the setBackgroundImage:forState:barMetrics: methods (probably on your appearance proxy) to set the background image. The text can be modified with setTitleTextAttributes:forState:. And finally, you'll need to change the divider for the possible states with setDividerImage:...
The docs are very informative as to how the images have to look.

UISegmentedControl custom background image

I have UINavigationBar setup as image - some wood texture. I want to insert UISegmentedControl with 4 buttons on that bar. Buttons should have same texture with slightly changed tint.
One solution would be to change tint alpha of buttons background color, so that texture in background can get trough, but as I set alpha for tint in IB it doesn't save value, it always gets back to value 1.
I cant get UISegmentedControl to show background image, so finally gave up and decide to search for help...
Effect that is desired is one in iBooks app, with buttons in Navigation Bar.
Any link or small help would be appreciated..
This post describes the steps involved and has sample code: http://idevrecipes.com/2010/12/13/wooduinavigation/
https://github.com/xhan/PlutoLand/blob/master/PlutoLand/UI/PLSegmentView.h
a custom SegmentView that can specify two images(normal, clicked)
Do not bother with one of those custom segmented control packages if you're on iOS 5 or later.
Per Dylan's suggestion, use the Appearance functionality in iOS 5+.
See the top answer here:
Customizing Left & Right UISegmentedControl Buttons