iOS 7 tabBar行,如何删除它?

苹果已经在iOS 7的tabBar上加了一条小小的线条,它应该在tabBar和UI之间作为阴影或淡入淡出

在这里输入图像说明

由于我使用的是定制的tabBar,因此这条线非常刺激。 你如何删除它? 请告诉我这是可能的,否则我需要重新devise我的整个应用程序大声笑….

/ 问候

*编辑

用以下代码行解决了我的问题:

[[UITabBar appearance] setShadowImage:[[UIImage alloc] init]]; 
  UIImage* tabBarBackground = [UIImage imageNamed:@"tabbar_bg.png"]; [[UITabBar appearance] setShadowImage:tabBarBackground]; [[UITabBar appearance] setBackgroundImage:tabBarBackground]; 

这些代码对我来说工作得很好(我没有真正的标签栏的背景图片):

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

我也使用这些代码来添加一个框架:

 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]; 

希望有所帮助。

在iOS 8中,可以通过在检查器中将标签栏样式设置为黑色来删除顶部边框。

迅速

简单的解决scheme:

在自定义标签栏类中input以下代码。 然后它会隐藏横向阴影线。

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

目标C

 [self.tabBar setValue:@(YES) forKeyPath:@"_hidesShadow"]; 
 self.tabBarController = [[UITabBarController alloc] init]; [[[self tabBarController] tabBar] setBackgroundImage:[UIImage imageNamed:@"YOURIMAGE.png"]]; [[UITabBar appearance] setShadowImage:[[UIImage alloc] init]]; 

我没有看到任何影响该分隔符的UITabBar API,但如果分隔符在UITabBar(一个UIView子类)内,我希望你可以插入一个新的高像素UIView的顶部。 您必须抓取您想要在其中显示的图像片段,然后在新视图中绘制该图像。 而且我不确定是否UITabBar会以某种方式阻止添加子视图或阻止子视图处于顶层。 但那就是我要开始的地方。

AppDelegate.m didFinishLaunchingWithOptions:方法中添加以下代码

 if ([[[UIDevice currentDevice] systemVersion] floatValue]>=7.0) [[UITabBar appearance] setShadowImage:[[UIImage alloc] init]]; 

这对我有效

 UIImage* tabBarBackground = [UIImage new]; if(!OSVersionIsAtLeastiOS7()) { tabBarBackground = [UIImage imageNamed:@"whitebg"]; } [[UITabBar appearance] setShadowImage:tabBarBackground]; [[UITabBar appearance] setBackgroundImage:tabBarBackground]; 

你可以用下面的代码隐藏“分隔线”:

[self.tabBar setValue:@(YES) forKeyPath:@"_hidesShadow"];

  [_tabBarController.tabBar setBackgroundImage:[UIImage imageNamed:@"tabtarsprnt"]]; //your custom image [self.tabBarController.tabBar setClipsToBounds:YES]; 

这个代码也解决了我的问题

在我的情况下,我还需要设置一个不同的阴影,最后唯一的工作,同时设置自定义阴影是添加一个单点高UIView 1点上面的标签栏:

  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];