The second method: 1) Declares the Uiimageview variable, storing the bottom horizontal line
@implementation Myviewcontroller {Uiimageview *navbarhairlineimageview;}
2) Add in Viewdidload:
Navbarhairlineimageview = [self findhairlineimageviewunder:navigationbar];
3) Realize the function of finding the bottom horizontal line
-(Uiimageview *) Findhairlineimageviewunder: (UIView *) View { if ([View IsKindOfClass:UIImageView.class] & & View.bounds.size.height <= 1.0) { return (Uiimageview *) view; } For (UIView *subview in view.subviews) { Uiimageview *imageview = [self findhairlineimageviewunder:subview]; if (ImageView) { return imageView; } } return nil;}
4) finally processed in the Viewwillappear,viewwilldisappear
-(void) Viewwillappear: (BOOL) animated { [Super viewwillappear:animated]; Navbarhairlineimageview.hidden = YES;} -(void) Viewwilldisappear: (BOOL) animated { [Super viewwilldisappear:animated]; Navbarhairlineimageview.hidden = NO;}
iOS Hidden nav bar 1px bottom horizontal line