How to make the Navigation Bar of an UINavigationController display at the bottom?

拜拜、爱过 提交于 2019-12-18 06:59:12

问题


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)


来源:https://stackoverflow.com/questions/5866283/how-to-make-the-navigation-bar-of-an-uinavigationcontroller-display-at-the-botto

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!