hide and show left navigation bar button on demand in iOS-7

落爺英雄遲暮 提交于 2019-12-03 12:51:05

Here is how I solved it

-(void) hideAndDisableRightNavigationItem
{
    [self.navigationItem.rightBarButtonItem setTintColor:[UIColor clearColor]];
    [self.navigationItem.rightBarButtonItem setEnabled:NO];
}

-(void) showAndEnableRightNavigationItem
{
    [self.navigationItem.rightBarButtonItem setTintColor:[UIColor blackColor]];
    [self.navigationItem.rightBarButtonItem setEnabled:YES];
}

Swift version of @learner answer

func hideAndDisableRightNavigationItem (){
  self.navigationItem.rightBarButtonItem?.enabled = false
  self.navigationItem.rightBarButtonItem?.tintColor = UIColor.clearColor()
}

func showAndEnableRightNavigationItem(){
   self.navigationItem.rightBarButtonItem?.enabled = true
   self.navigationItem.rightBarButtonItem?.tintColor = UIColor. blackColor()
}
Nex Mishra

Here is what I did. On the initial screen I wanted to hide the navigation bar:

 self.navigationController.navigationBarHidden = YES;

On the second screen I wanted to show the navigation bar so I set:

 self.navigationController.navigationBarHidden = NO;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!