首页 > 移动平台 > 详细

iOS隐藏导航条1px的底部横线

时间:2015-12-04 20:35:46      阅读:339      评论:0      收藏:0      [点我收藏+]

第二种方法:1)声明UIImageView变量,存储底部横线

@implementation MyViewController {

UIImageView *navBarHairlineImageView;
}

2)在viewDidLoad中加入:

navBarHairlineImageView = [self findHairlineImageViewUnder:navigationBar];

3)实现找出底部横线的函数

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

4)最后在viewWillAppear,viewWillDisappear中处理

- (void)viewWillAppear:(BOOL)animated {
  [super viewWillAppear:animated];
  navBarHairlineImageView.hidden = YES;
}
- (void)viewWillDisappear:(BOOL)animated {
  [super viewWillDisappear:animated];
  navBarHairlineImageView.hidden = NO;
}

iOS隐藏导航条1px的底部横线

原文:http://www.cnblogs.com/tian-sun/p/5019928.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!