According to the requirements of the product requirements of the interface to remove the bottom of the navigation bar, the next controller also need to have a bottom line.
Use the following code to implement the
Hide the black line when the page appears
-(void) Viewwillappear: (BOOL) animated
{
[Self.navigationController.navigationBar setbackgroundimage:[uiimage new] forbarmetrics:uibarmetricsdefault];
[Self.navigationController.navigationBar setshadowimage:[uiimage New]];
_navbarhairlineimageview.hidden = YES;
}
Let Navigationbar restore the style when the page disappears
-(void) Viewwilldisappear: (BOOL) animated{
[Self.navigationController.navigationBar Setbackgroundimage:nil Forbarmetrics:uibarmetricsdefault];
[Self.navigationController.navigationBar Setshadowimage:nil];
and define a imageview to equate this black line.
Uiimageview *navbarhairlineimageview;
_navbarhairlineimageview = [self findHairlineImageViewUnder:self.navigationController.navigationBar];
}
The only downside to this method is the translucent (transparent) properties that affect the navigation bar
Method 2: Find the black line and do the processing:
A way to find this black line (Findhairlineimageviewunder):
-(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;
}
The same time when the interface appears to open the hidden
-(void) Viewwillappear: (BOOL) animated
//{
_navbarhairlineimageview.hidden = YES;
//}
Let it appear when the page disappears
-(void) Viewdidappear: (BOOL) animated
{
_navbarhairlineimageview.hidden = NO;
}