代码改变世界

IOS自定义导航栏及高度

2017-08-02 19:47  zhaosn  阅读(1852)  评论(0)    收藏  举报

UIView *headView= [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 120)];

 headView.backgroundColor=[UIColor clearColor];

[headView addSubview:*****];

//self.navigationItem.titleView = headView; //只把headView添加到titleView

 [self.navigationController.navigationBar addSubview:headView];//以headView实际宽度显示

 

 

-(void)viewWillAppear:(BOOL)animated{

    [super viewWillAppear:animated];

    CGRect rect = self.navigationController.navigationBar.frame;

    self.navigationController.navigationBar.frame = CGRectMake(rect.origin.x,rect.origin.y,rect.size.width,100);

    [self.navigationItem setHidesBackButton:YES animated:YES];//隐藏返回按钮

}

 

 

导航栏下面视图  起始Y值为64(状态栏20 + navigationBar 44)