A way to get rid of a black line below the navigation bar during the project
Default Uinavigationbar Style
Prepare the background for replacement
The effect after replacement
if ([Self.navigationController.navigationBar respondstoselector: @selector (setbackgroundimage:forbarmetrics:)]) {
[Self.navigationController.navigationBar setbackgroundimage:[uiimage imagenamed:@ "TOP_BG"] forbarmetrics: Uibarmetricsdefault];
}
In iOS7, after executing the above code to replace the background image of Navigationbar, a very obvious black line appears, how do you remove the black lines?
-----------------------------------------------------------------------------------
Wait for one hours no one answer, good sad!
Fortunately, I solved it myself!
Here's how:
if ([Self.navigationController.navigationBar respondstoselector: @selector (setbackgroundimage:forbarmetrics:)]) {
Nsarray *list=self.navigationcontroller.navigationbar.subviews;
for (the ID obj in list) {
if ([obj Iskindofclass:[uiimageview class]]) {
Uiimageview *imageview= (Uiimageview *) obj;
Imageview.hidden=yes;
}
}
Uiimageview *imageview=[[uiimageview alloc] Initwithframe:cgrectmake (0,-20, 420, 64)];
Imageview.image=[uiimage imagenamed:@ "TOP_BG"];
[Self.navigationController.navigationBar Addsubview:imageview];
[Self.navigationController.navigationBar Sendsubviewtoback:imageview];
}
Final effect:
How to remove the black line below Uinavigationbar in iOS7