简体   繁体   中英

remove toolbar from navigation controller

I have a navigation controller where I add a toolbar based on user input.

When the user hits back to the home screen. I don't want the toolbar.

self.navigationcontroller.toolbar.hidden = YES;

This just hides the toolbar and the UIImage on the homepage is now shifted up the 40px and the black background appears where the toolbar is hidden.

How can I REMOVE the toolbar so the image doesn't get pushed up.

self.navigationController.toolbar.hidden = YES;

需要替换为...

self.navigationController.toolbarHidden = YES; 

To keep the position of the child VC's frame move it with 40px down (animation with duration 0.25 fe), when you hide the toolbar, or change the navigation controllers bounds origin with origin.y +40, just like you would do, when you are hiding the status bar. But i think an empty space will remain, you should do something with it.

为了快速,你需要写:

        self.navigationController?.isToolbarHidden = true

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM