开发者

how to hide navigationbar when i push from navigation controller?

开发者 https://www.devze.com 2022-12-09 21:22 出处:网络
how to hide top bar in UIViewcon开发者_StackOverflowtroller when i push from navigation controller using

how to hide top bar in UIViewcon开发者_StackOverflowtroller when i push from navigation controller using pushViewController ? any help please?


Put this code in the view controller you want to hide the navigation bar for.

- (void) viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:animated];
}

And you may also want to stick this in there, depending on your needs:

- (void) viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:animated];
}


Here's how to do it in Swift 3:

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    self.navigationController?.setNavigationBarHidden(true, animated: animated)
}

P.S. I found that if you set animated to false, a black bar appears on push. But when it is set to true it's smooth as silk!


For iOS 8 May be this work around could work it

CATransition* transition = [CATransition animation];
        transition.duration = 0.3;
        transition.type = kCATransitionPush;
        transition.subtype = kCATransitionFromRight;
        [self.navigationController.view.layer addAnimation:transition forKey:kCATransition];
        [self.navigationController setNavigationBarHidden:TRUE animated:FALSE];
        [self.navigationController pushViewController:productViewObj animated:FALSE];
        [productViewObj.navigationController setNavigationBarHidden:TRUE animated:FALSE];
        [productViewObj release];
0

精彩评论

暂无评论...
验证码 换一张
取 消