iOS去掉navigationBar下面的一条横线

释放双眼,带上耳机,听听看~!
1.第一种方法

    [[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];

    [[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];


2.第二种方法


@interface BaseViewController (){

    UIImageView *navBarHairlineImageView;

}

- (void)viewDidLoad {

    [super viewDidLoad];

    navBarHairlineImageView = [self findHairlineImageViewUnder: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 = [self findHairlineImageViewUnder:subview];

        if (imageView) {

            return imageView;

        }

    }

    return nil;

}



- (void)viewWillAppear:(BOOL)animated

{

    [super viewWillAppear:animated];

    navBarHairlineImageView.hidden = YES;

}

- (void)viewWillDisappear:(BOOL)animated

{

    [super viewWillDisappear:animated];

    navBarHairlineImageView.hidden = NO;

}

 

人已赞赏
iOS文章

关于 @synchronized,

2019-11-1 11:41:36

iOS文章

iOS-NSString汉子转拼音

2019-11-1 14:19:18

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
有新消息 消息中心
搜索