Is there any way to make the default navigation bar of an UINavigationController
display at the bottom instead of the top?
I know that there is an UIToolbar
that can be displayed at the bottom, but that one is specific to each view and does not carry the "back" button.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
If you create your view using a NIB, then it is rather simple - select navigation bar in attributes->bottom bar. If not then you should access navigation bar directly and change its coordinates. In your view controller:
CGRect oldRect = self.navigationController.navigationBar.frame;
self.navigationController.navigationBar.frame = CGRectMake(x, y, oldRect.width, oldRect.height);
where x and y are coordinates to place your navigation bar.
回答2:
Try this :
bottomNav = [[UINavigationBar alloc] initWithFrame:CGRectMake(0.0, self.view.frame.size.height - 20, self.view.frame.size.width, 44.0)];
bottomNav.barStyle = UIBarStyleBlackOpaque;
[self.parentViewController.view addSubview:bottomNav];
回答3:
I think you can but i don't think it will approved by Apple
@implementation UINavigationBar (CustomBar)
- (void)drawRect:(CGRect)rect {
self.frame = CGRectMake(0, 436, 320, 44);
}
回答4:
Here is the swift version:
var bottomNav = UINavigationBar(x: 0, y: view.frame.size.height - 20, w: view.frame.size.width, h: 44)
bottomNav.barStyle = UIBarStyle.Black
parentViewController?.view.addSubview(bottomNav)