Search code examples
iosobjective-cuitabbar

UITabbar difference in iOS 5 and iOS 6


I'm stumped on UITabBar (again).

I have a UITabbar that I am using a background image for and directly above it I have another UIImage. Everything looks fine in iOS 5 (device and simulator) but on iOS 6 there is a sharp line at the top of the tab bar.

On iOS 5 https://i.sstatic.net/Bjm7i.png

On iOS 6 https://i.sstatic.net/b3ALg.png

I'm setting the background image as follows :

[[UITabBar appearance] setBackgroundImage:[UIImage imageNamed:@"bottombar.png"]];

Any idea why it works in iOS 5 but not in iOS 6? Images are not the issue as I've tried creating two UIImages in that same view and placed them one above the other and they look fine.

My (noob-ish) guess is that iOS 6 has added some sort of an effect at the top of the tabbars. If so, is there a way to remove it?

Help will be truly appreciated.


Solution

  • Found the answer. Thanks to Pixi on another forum.

    [[UITabBar appearance] setShadowImage:[UIImage imageNamed:@"shadow.png"]];
    

    Where shadow.png is a 1x1 transparent image. The tab bar was casting a shadow which was resulting in the sharp line at the top of the tab bar. The transparent image gets rid of that.

    May be this will help someone else as well in the future.