According to the requirements of the product requirements of the interface navigation bar to remove the bottom line, the next controller needs 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];
// redefine a imageview to equate to this black Line
//uiimageview *navbarhairlineimageview;
_navbarhairlineimageview = [self findhairlineimageviewunder:self. Navigationcontroller. Navigationbar];
}
The only downside to this method is that it affects the translucent ( transparent ) property of the navigation bar.
Method 2: find the black line , and then 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 when the interface appears to open the hidden
-(void) Viewwillappear: (BOOL) animated
//{
_navbarhairlineimageview.hidden = YES;
//}
when the page disappears, let it appear.
-(void) Viewdidappear: (BOOL) animated
{
_navbarhairlineimageview. Hidden = NO;
}
iOS shows or hides the bottom line of the navigation bar