美文网首页
关于NavigationController的简单设置

关于NavigationController的简单设置

作者: NICE_KEY | 来源:发表于2016-06-24 21:30 被阅读43次

    删除navigationBar下面的横线方法

    • 声明用来存放下方横线的属性
    _navBarHairlineImageView = [self findHairlineImageViewUnder:self.navigationController.navigationBar];
    
    
    • 设置找到该横线的方法
    - (UIImageView *)findHairlineImageViewUnder:(UIView *)view {
          /** 如果这个类是UIImageView类并且高度小于1 的话直接返回. */
        if ([view isKindOfClass:UIImageView.class] && view.bounds.size.height <= 1.0) {
            return (UIImageView *)view;
        }
         /** 遍历传入的view上面的子视图. */
        for (UIView *subView in view.subviews) {
         /** 回调此方法. 直到找到下方横线的ImageView并返回*/
            UIImageView *imageView = [self findHairlineImageViewUnder:subView];
            if (imageView) {
                return imageView;
            }
        }
        return nil;
    }
    
    
    • - (void)viewWillAppear:(BOOL)animated- (void)viewWillDisappear:(BOOL)animated两个方法中设置view 的隐藏.
     - (void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];
        _navBarHairlineImageView.hidden = YES;
    }
     - (void)viewWillDisappear:(BOOL)animated {
        [super viewWillDisappear:animated];
        _navBarHairlineImageView.hidden = NO;
    }
    
    

    这样就可以是下方的横线消失.

    设置title字体颜色和大小

        self.navigationItem.title = @"通讯录";
        self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor],NSFontAttributeName : [UIFont boldSystemFontOfSize:18]};
        
    
    

    设置leftBarButtonItem的颜色

        self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    

    相关文章

      网友评论

          本文标题:关于NavigationController的简单设置

          本文链接:https://www.haomeiwen.com/subject/bnaodttx.html