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:
Related
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;
When setting the tint color of a UISegmentedControl using the Appearance API, the color of the text in each unselected segment takes the color of the UILabel instead only after switching tabs.
A sample program to test this (screenshots below):
Load the program and look at the first tab. Everything is normal, the labels are red and the segments are blue.
Switch away to the second tab, everything is still fine.
Switch back to the first tab, you will see that the segments have changed to be red instead of blue like they should.
App was just loaded, everything is fine:
After switching tabs, color is wrong:
Code responsible (in the app delegate for testing, but happens elsewhere):
[[UILabel appearance] setTextColor:[UIColor redColor]];
[[UISegmentedControl appearance] setTintColor:[UIColor blueColor]];
I have sent this information to Apple in a bug report. They asked for a sample project, but I haven't gotten an answer yet. This only shows up on IOS 7.1. On 7.0, this doesn't happen.
Are there any suggestions or temporary fixes that would resolve this? It makes my app look bad even though I don't think it's my fault (the red is just to test, that would make anybody's app look bad). I have tried setting controls manually by setting the tint of the specific control instead of using the appearance API, but the problem is still there.
As discussed in the comments, use [[UILabel appearanceWhenContainedIn:[UISegmentedControl class], nil] setTextColor:[UIColor blueColor]]; to set the appearance of the internal label contained in a segment control.
Per the Apple documentation: Setting the tintColor property by using the appearance proxy APIs is not supported in iOS 7.
iOS 7 UI Transition Guide
You can also specify text attributes like of UISegmentedControl like font, using setTitleTextAttributes:forState.
Actually it's shiny by default. However, many of my tab bars do not have shiny icon.
I wonder what did I do wrong that it fails to be shiny?
I look around and I saw that a way to eliminate the shiny glossy image is by doing
[[UITabBar appearance] setSelectionIndicatorImage:SomeCustomImage];
That's what happen. I use custom selector image. Well, what about if I still want that custom selector image and I still want the shiny look?
I look at the code and see no difference.
I set image tint to default and it's still not shiny.
Note: I figured out the problem
The other tab bars use custom selected image
[[UITabBar appearance] setSelectionIndicatorImage:SomeCustomImage];
That removes the gloss.
Well, how do I use setSelectionIndicatorImage and yet maintain shiny glossy look.
I have an NSWindow, and I'm using this code to add a bottom-metal-bar at the bottom.
[MyWindow setContentBorderThickness:40.0 forEdge:NSMinYEdge];
That works fine. But, once I use this:
[MyWindow setBackgroundColor: [NSColor redColor]];
The red covers the bar at the bottom. The bar shows correctly without the background color.
Yes, it would appear that changing the background-color of an NSWindow negates its bottom border. In order to achieve both effects, you can do one of two things:
In Interface Builder, move all your interface elements to a subclass of NSView that draws its background and add the view to your window.
Create an NSView that emulates the bottom border of your window and set the window's background color.
Personally, I would go for the first option, because it requires less work (trying to emulate a bottom border will be difficult, even with NSGradient) , but both are a possibility.
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];