->写项目的时候设计总会觉得系统带的黑线都太难看了,要求程序上把这个去掉,本人每次都是要去找一下,然后有的可能还不好用,可能是我哪里用的不对吧,这里自己总结下,也希望可以帮到有同样需求的人哦~
Tabbar
//隐藏系统Tabbar上面黑线
CGRect rect = CGRectMake(0, 0, kScreen_Width, 0.5);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [[UIColor clearColor] CGColor]);
CGContextFillRect(context, rect);
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImage *image = ImageNamed(@"tab_img_bg");
[self.tabBar setBackgroundImage:img];
[self.tabBar setShadowImage:image];
注:这里的 “tab_img_bg” 是个人加了一个黑色投影的切图在tabar上
导航栏
//隐藏系统导航栏下面的黑线
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setShadowImage:[UIImage new]];
//全局设置返回按钮
UIImage *image = [UIImage imageNamed:@"nav_back"];
image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
[UINavigationBar appearance].backIndicatorTransitionMaskImage = image;
[UINavigationBar appearance].backIndicatorImage = image;
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@" " style:UIBarButtonItemStylePlain target:nil action:nil];
//修改导航栏标题的同时不改变tabbar的标题
self.navigationItem.title = "标题"
效果图
344843283D68BAB5E1AC33FD93374FB1.png
网友评论