去掉导航条底部线条
[self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]];
去掉tabbar顶部线条
// tabbar里面有三个内置的image:背景图片、选中时图片、阴影图片,然后修改这三个image
CGRect rect = CGRectMake(0, 0, SCREENWIDTH, SCREENHEIGHT);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [[UIColor clearColor] CGColor]);
CGContextFillRect(context, rect);
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[TBC.tabBar setBackgroundImage:img];
[TBC.tabBar setShadowImage:img];
其实并没有删除横线(remove掉),只是把它变成透明的不影响操作和界面美观而已(视觉错)。
本文介绍如何在iOS应用中使用Swift代码去除UINavigationController的底部线条和UITabBarController的顶部线条,通过设置背景和阴影图片为透明实现视觉上的去除效果。
1万+

被折叠的 条评论
为什么被折叠?



