Last Updated: February 25, 2016
·
2.445K
· apisit

Remove that 1px line from UINagivationBar in iOS7.

There must be a way to remove it in the future but for now here is how.

[self.navigationController.navigationBar.subviews enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL stop) {
if ([obj isKindOfClass:NSClassFromString(@"_UINavigationBarBackground")]){
UIView
v = obj;
[[v.subviews objectAtIndex:1] removeFromSuperview];
*stop=YES;
}
}];

Picture

3 Responses
Add your response

Thanks, I looked for that code, but one thing: I would add that line to prevent an exception:

[self.navigationController.navigationBar.subviews enumerateObjectsUsingBlock:
 ^(id obj, NSUInteger idx, BOOL *stop) {
     if ([obj isKindOfClass:NSClassFromString(@"_UINavigationBarBackground")]){
         UIView* v = obj;
         if ([v.subviews count] > 0) {
             [[v.subviews objectAtIndex:0] removeFromSuperview];
             *stop=YES;
         }
     }
 }];
over 1 year ago ·

Thanks :)

over 1 year ago ·

But it change color of navigation bar lightly

over 1 year ago ·