iOS 7 tabBar-line, how to remove it?

2019-03-08 22:53发布

Apple has added a tiny line over the tabBar in iOS 7 which is supposed to work as a shadow or fade between the tabBar and the UI

enter image description here

Since I am using a custom-made tabBar the line is quite irritating. How do you remove it? Please tell me it is possible, otherwise I need to redesign my whole app lol....

/ Regards

*Edit

Sloved my problem with the following line of code:

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

12条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-03-08 23:00

Swift

Nice simple solution:

Write this below code in your custom tab bar class. Then it will hide horizontal shadow line.

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

Objective C

[self.tabBar setValue:@(YES) forKeyPath:@"_hidesShadow"];
查看更多
可以哭但决不认输i
3楼-- · 2019-03-08 23:00

Add the following code in AppDelegate.m didFinishLaunchingWithOptions: method

if ([[[UIDevice currentDevice] systemVersion] floatValue]>=7.0)
 [[UITabBar appearance] setShadowImage:[[UIImage alloc] init]];
查看更多
一纸荒年 Trace。
4楼-- · 2019-03-08 23:01

These code works pretty well for me (I don't really have background image for tab bar):

[tab_main.tabBar setBackgroundImage:[[UIImage alloc] init]];
[[UITabBar appearance] setShadowImage:[[UIImage alloc] init]];

And I use these code to add a frame too:

UIColor* color_green = UIColorFromRGB(0x348e5b);
tab_main.tabBar.layer.borderWidth = 0.50;
tab_main.tabBar.layer.borderColor = color_green.CGColor;
[[UITabBar appearance] setTintColor:color_green];

Hope that helps.

查看更多
Fickle 薄情
5楼-- · 2019-03-08 23:02

In my case I also needed to set a different shadow, in the end the only thing that worked while also setting a custom shadow was to add a single-point high UIView 1 point above the tab bar:

    UIView *whiteLine = [[UIView alloc] initWithFrame:CGRectMake(0.0, -1.0, self.tabBar.frame.size.width, 1.0)];
    whiteLine.backgroundColor = [UIColor whiteColor];
    [self.tabBar addSubview:whiteLine];
查看更多
你好瞎i
6楼-- · 2019-03-08 23:05

now you can use it, with this line:

self.tabBarController.tabBar.barStyle = UIBarStyleBlack; 
查看更多
劫难
7楼-- · 2019-03-08 23:06

In iOS 8 the top border can be removed by setting the tab bar style to black in the inspector.

查看更多
登录 后发表回答