1. 程式人生 > >去掉navigationBar下面的一條橫線

去掉navigationBar下面的一條橫線

1.第一種方法

    [[UINavigationBarappearance] setBackgroundImage:[[UIImagealloc] init] forBarPosition:UIBarPositionAnybarMetrics:UIBarMetricsDefault];

    [[UINavigationBarappearance] setShadowImage:[[UIImagealloc] init]];

2.第二種方法

@interface BaseViewController (){

UIImageView *navBarHairlineImageView;

}

- (void)viewDidLoad {

    [superviewDidLoad];

navBarHairlineImageView = [selffindHairlineImageViewUnder:self.navigationController.navigationBar];

// Do any additional setup after loading the view from its nib.

}

- (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 = [selffindHairlineImageViewUnder:subview];

if (imageView) {

return imageView;

        }

    }

returnnil;

}

- (void)viewWillAppear:(

BOOL)animated

{

    [superviewWillAppear:animated];

navBarHairlineImageView.hidden = YES;

}

- (void)viewWillDisappear:(BOOL)animated

{

    [superviewWillDisappear:animated];

navBarHairlineImageView.hidden = NO;

}