I have a UINavigationController with a UINavigationBar at the top of the screen and a UIToolbar at the bottom. I want to make the toolbar a bit taller. Here's my code:
CGRect toolbarFrame = self.navigationController.toolbar.frame;
toolbarFrame.size.height += 20;
toolbarFrame.origin.y -= 20;
self.navigationController.toolbar.frame = toolbarFrame;
[self setToolbarItems:@[myButton]];
self.navigationController.toolbarHidden = NO;
This seems like it should work and doesn't generate any errors/warnings, but the size of the toolbar stays at the defaults.
Is there a way to change the size of a UINavigationController's UIToolbar, or should I just make a custom UIToolbar for this?
I've tried your code and just adjust your code's sequence. It will work:
[self setToolbarItems:@[myButton]];
self.navigationController.toolbarHidden = NO;
CGRect toolbarFrame = self.navigationController.toolbar.frame;
toolbarFrame.size.height += 20;
toolbarFrame.origin.y -= 20;
self.navigationController.toolbar.frame = toolbarFrame;
I think this is because setToolbarItems
will adjust the appearance of your tool bar. So you need firstly do other init-related things. Then adjust its appearance(such change its frame.)
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.