Hide the line at the bottom of the navigation bar method 1 (single-page setup)

[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setShadowImage:[UIImage new]];
Copy the code

If you don’t want to affect the navigation transparency of other pages, viewWillDisappear sets it to nil:

[self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setShadowImage:nil];
Copy the code

Approach 2(Global Settings)

[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
 
[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
Copy the code

Methods 3

self.navigationController.navigationBar.clipsToBounds = YES;
Copy the code

The code for setting the color of the bottom line of the navigation bar:

UINavigationBar *navigationBar = self.navigationController.navigationBar; [navigationBar setBackgroundImage:[[UIImage alloc] init] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault]; NavigationBar setShadowImage:[UIImage imageWithColor:[UIColor redColor]]];Copy the code
@implementation UIImage (ColorImage) + (UIImage *)imageWithColor:(UIColor *)color{CGRect rect = CGRectMake(0.0f, 0.0f, 1.0 f, 1.0 f); UIGraphicsBeginImageContext(rect.size); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColor(context, [color CGColor]); CGContextFillRect(context, rect); UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return image; }@endCopy the code

Fixed navigationController sideslip shutdown failure

self.navigationController.interactivePopGestureRecognizer.delegate = (id)self
Copy the code

Hide the text after the back button

 [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60)
                                                         forBarMetrics:UIBarMetricsDefault];
Copy the code

From: blog.csdn.net/wujakf/arti…