导航栏下方横线去除

2016-04-01  本文已影响202人  vincent涵

这是个老问题了,奈何不知道是自己的项目原因还是Xcode版本更新,网上搜了好多都解决不掉,找了好久最后终于找到一个能解决的,之前项目太忙忘记记录转自何方,现在想起来整理,感谢原作者。


#import "RootViewController.h"

@interface RootViewController ()

@property (nonatomic, strong)UIImageView *contentLineImageView;

@end

@implementation RootViewController

- (void)viewWillAppear:(BOOL)animated {

        [super viewWillAppear:animated];

        _contentLineImageView.hidden = YES;

}

- (void)viewWillDisappear:(BOOL)animated {

        [super viewWillDisappear:animated];

        _contentLineImageView.hidden = NO;

}

// 消除导航栏下的线

- (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;

}

- (void)viewDidLoad {

        [super viewDidLoad];

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

}

上一篇 下一篇

猜你喜欢

热点阅读