怎么删除navigationbar下边的黑线

2017-05-23  本文已影响0人  这个姑凉儿

1.定义属性

@interface LiveViewController ()

@property(nonatomic,strong)UIImageView *navBarHairlineImageView;

@end

2.再定义一个imageview来等同于这个黑线

- (void)viewDidLoad {

[super viewDidLoad];

//再定义一个imageview来等同于这个黑线

_navBarHairlineImageView = [self findHairlineImageViewUnder:self.navigationController.navigationBar];

}

3.通过一个方法来找到这个黑线(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;

}

上一篇下一篇

猜你喜欢

热点阅读