Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS UITabBar : Remove top shadow gradient line

I implemented a custom UITabBar and I still have this gradient/shadow on top of it. I added

[self.tabBar setBackgroundImage:[UIImage imageNamed:@"navBarBottom.png"]];

which is just changing the background but keeping the shadow gradient.

What am I doing wrong ? Is there anything to specify to get rid of it ?

What I have :

top shadow

What I want :

without shadow

Thank you.

like image 789
httpete Avatar asked Jan 17 '13 02:01

httpete


4 Answers

Similary in answer for this question ... if You don't want to mess with any kind of 1x1 transparent image, this work's too:

[[UITabBar appearance] setBackgroundImage:[[UIImage alloc] init]]; 
[[UITabBar appearance] setShadowImage:[[UIImage alloc] init]];

In swift:

UITabBar.appearance().shadowImage = UIImage()
UITabBar.appearance().backgroundImage = UIImage()
like image 91
JakubKnejzlik Avatar answered Nov 13 '22 00:11

JakubKnejzlik


Try setting a 1x1 pixel transparent shadow image for the UITabBar:

[[UITabBar appearance] setShadowImage:[UIImage imageNamed:@"transparentShadow.png"]];
like image 22
Brian Liang Avatar answered Nov 13 '22 00:11

Brian Liang


Swift

Try this for your custom tab bar. It will hide horizontal shadow line.

self.tabBar.setValue(true, forKey: "_hidesShadow")

Objective C

[self.tabBar setValue:@(YES) forKeyPath:@"_hidesShadow"];
like image 16
Sourabh Sharma Avatar answered Nov 12 '22 22:11

Sourabh Sharma


Swift 4

UITabBar.appearance().layer.borderWidth = 0.0
UITabBar.appearance().clipsToBounds = true
like image 16
Ahmadreza Avatar answered Nov 12 '22 22:11

Ahmadreza