UIImageView * _navBarHairlineImageView;
_navBarHairlineImageView = [self findHairlineImageViewUnder:self.navigationController.navigationBar];
-(void)viewWillAppear:(BOOL)animated
{
_navBarHairlineImageView.hidden = YES;
}
-(void)viewDidDisappear:(BOOL)animated
{
_navBarHairlineImageView.hidden = NO;
}
//通过一个方法来找到这个黑线(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;
}
https://www.jianshu.com/p/effa4a48f1e3
网友评论