UINavigationController点击事件控制隐藏与显示(UITabBarController也同样适用)

@interface ViewController ()
{
    BOOL isflage;
}
@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    isflage = YES;
    [self.navigationController setNavigationBarHidden:isflage animated:YES];

}

#pragma mark onClick

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    isflage = !isflage;
    [self.navigationController setNavigationBarHidden:isflage animated:YES];
}

@end

上述代码的实现结果就是:

先隐藏navigationController,之后点击会显示,再点击又会隐藏,超简单吧。

同样tabBarController也是同样的实现结果。

tabBarController

你可能感兴趣的:(导航栏,点击隐藏显示)