iOS 去掉tabbar顶部的线(主要用于自定义tabbar)

有两种方法:

1.在AppDelegate中添加

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

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

2.在tabbarVC中添加

其实并没有删除横线(remove掉),只是把它变成透明的不影响操作和界面美观而已(视觉错)

CGRect rect = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);

UIGraphicsBeginImageContext(rect.size);

CGContextRef context = UIGraphicsGetCurrentContext();

CGContextSetFillColorWithColor(context, [UIColor clearColor].CGColor);

CGContextFillRect(context, rect);

UIImage *img = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

[self.tabBar setBackgroundImage:img];

 [self.tabBar setShadowImage:img];

你可能感兴趣的:(iOS 去掉tabbar顶部的线(主要用于自定义tabbar))