This line will be available by default
The first method:
Uinavigationbar *navigationbar = Self.navigationController.navigationBar;
White.png picture oneself to download a pure white color block, or own PS do a
[Navigationbar setbackgroundimage:[uiimage imagenamed:@ "White.png"]
Forbarposition:uibarpositionany
Barmetrics:uibarmetricsdefault];
[Navigationbar setshadowimage:[uiimage New]];
The effect is as follows (where the original gray background color is replaced by white.png):
PS: This is the only official use to hide this line, but there is a flaw-delete the translucency (translucent)
The second method:
1 declare uiimageview variable, store bottom horizontal line
@implementation Myviewcontroller {
uiimageview *navbarhairlineimageview;
}
2) by adding 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 in the viewwillappear,viewwilldisappear processing
-(void) Viewwillappear: (BOOL) animated {
[Super viewwillappear:animated];
Navbarhairlineimageview.hidden = YES;
}
-(void) Viewwilldisappear: (BOOL) animated {
[Super viewwilldisappear:animated];
Navbarhairlineimageview.hidden = NO;
}
The effect is as follows:
PS: The second way to keep bar translucent
This article permanent address: http://blog.it985.com/9808.html
This article comes from IT985 blog, reprint, please indicate the source and corresponding link.