17

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):

home screen feedback screen

One one screen, the color is weirdly lighter. This screen is a UIWebView.

webview screen

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.

settings screen

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.

Bartłomiej Semańczyk
  • 59,234
  • 49
  • 233
  • 358
Joel Derfner
  • 2,207
  • 6
  • 33
  • 45

2 Answers2

24

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.

CSmith
  • 13,318
  • 3
  • 39
  • 42
  • Thanks--but the problem is that I'm using not a `UITabBar` but a `UITabBarController`, which doesn't seem to have a translucent property. Or am I wrong? Any thoughts? – Joel Derfner Sep 20 '13 at 00:59
  • 2
    Did you try `[self.tabBarController.tabBar setTranslucent:NO];`? Keep in mind the the `UITabBarController` is not a `UIView`... it's an object that, among other responsibilities, manages a `UITabBar`. You have to drill into the `.tabBar` property to make modifications. – Matt H. Sep 20 '13 at 04:18
  • Hunh--that did it! But I thought the `tabBar` property was read-only? – Joel Derfner Sep 20 '13 at 14:11
  • From the documentation: "@property(nonatomic,readonly) UITabBar *tabBar You should never attempt to manipulate the UITabBar object itself stored in this property. If you attempt to do so, the tab bar view throws an exception. To configure the items for your tab bar interface, you should instead assign one or more custom view controllers to the viewControllers property.... The tab bar view provided by this property is only for situations where you want to display an action sheet using the showFromTabBar: method of the UIActionSheet class." – Joel Derfner Sep 20 '13 at 14:12
1

You can also uncheck "Translucent" at the Attributes Inspector: enter image description here

dianakarenms
  • 2,609
  • 1
  • 22
  • 22