How to make the Navigation Bar of an UINavigationController display at the bottom?
-
28-10-2019 - |
Pergunta
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.
Solução
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.
Outras dicas
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];
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);
}
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)
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow