隱藏導航欄底部的線條
方法1 (單頁面設置)app
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; [self.navigationController.navigationBar setShadowImage:[UIImage new]];
若是不想影響其餘頁面的導航透明度,viewWillDisappear將其設置爲nil便可:
.net
[self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault]; [self.navigationController.navigationBar setShadowImage:nil];
方法2(全局設置)code
[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault]; [[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
方法3blog
self.navigationController.navigationBar.clipsToBounds = YES;
設置導航欄底部線條顏色的代碼:ip
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側滑關閉失效的問題it
self.navigationController.interactivePopGestureRecognizer.delegate = (id)self;
隱藏返回按鈕後面的文字io
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60) forBarMetrics:UIBarMetricsDefault];
---------------------
做者:wuWuJK
來源:CSDN
原文:https://blog.csdn.net/wujakf/article/details/78584325
版權聲明:本文爲博主原創文章,轉載請附上博文連接!class