->寫項目的時候設(shè)計總會覺得系統(tǒng)帶的黑線都太難看了,要求程序上把這個去掉,本人每次都是要去找一下,然后有的可能還不好用,可能是我哪里用的不對吧,這里自己總結(jié)下,也希望可以幫到有同樣需求的人哦~
Tabbar
//隱藏系統(tǒng)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上
導(dǎo)航欄
//隱藏系統(tǒng)導(dǎo)航欄下面的黑線
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setShadowImage:[UIImage new]];
//全局設(shè)置返回按鈕
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];
//修改導(dǎo)航欄標(biāo)題的同時不改變tabbar的標(biāo)題
self.navigationItem.title = "標(biāo)題"
效果圖

344843283D68BAB5E1AC33FD93374FB1.png