隱藏導航欄底部的線條
辦法1 (單頁面設置)
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setShadowImage:[UIImage new]];
假如不想影響其他頁面的導航通明度,viewWillDisappear將其設置為nil即可:
[self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setShadowImage:nil];
辦法2(全局設置)
[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
辦法3
self.navigationController.navigationBar.clipsToBounds = YES;
設置導航欄底部線條顏色的代碼:
UINavigationBar *navigationBar = self.navigationController.navigationBar;
[navigationBar setBackgroundImage:[[UIImage alloc] init] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault]; //此處使底部線條顏色為白色
[navigationBar setShadowImage:[UIImage imageWithColor:[UIColor redColor]]];
@implementation UIImage (ColorImage)
+ (UIImage *)imageWithColor:(UIColor *)color{
CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext(); return image;
}@end
修復navigationController側滑封閉生效的問題
self.navigationController.interactivePopGestureRecognizer.delegate = (id)self
隱藏前往按鈕前面的文字
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60)
forBarMetrics:UIBarMetricsDefault];
本文轉自: http://www.jianshu.com/p/aa547432eae0
【iOS隱藏導航欄底部的線條& UINavigationBar小技巧】的相關資料介紹到這裡,希望對您有所幫助! 提示:不會對讀者因本文所帶來的任何損失負責。如果您支持就請把本站添加至收藏夾哦!