UINavigationController--隐藏下方横线

隐藏导航栏底部的线条
方法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

相关文章
相关标签/搜索