【问题标题】:How to make the Navigation Bar of an UINavigationController display at the bottom?如何使 UINavigationController 的导航栏显示在底部?
【发布时间】:2011-08-17 12:00:51
【问题描述】:

有没有办法让UINavigationController 的默认导航栏显示在底部而不是顶部? 我知道有一个UIToolbar可以显示在底部,但是那个是特定于每个视图的,不带有“返回”按钮。

【问题讨论】:

    标签: iphone ios uinavigationcontroller navigation navigationbar


    【解决方案1】:

    如果您使用NIB 创建视图,那么它相当简单- 在属性-> 底部栏中选择导航栏。如果没有,那么您应该直接访问导航栏并更改其坐标。在您的视图控制器中:

    CGRect oldRect = self.navigationController.navigationBar.frame;
    self.navigationController.navigationBar.frame = CGRectMake(x, y, oldRect.width, oldRect.height);
    

    其中 x 和 y 是放置导航栏的坐标。

    【讨论】:

    • 把这个放到viewWillApprear里,就可以了。但是当通过从其他视图中关闭模式视图返回时,它会返回顶部。即使这会再次被调用,它只是停留在顶部。好奇怪!
    【解决方案2】:

    试试这个:

    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】:

      我认为你可以,但我认为它不会得到 Apple 的批准

      @implementation UINavigationBar (CustomBar)
      - (void)drawRect:(CGRect)rect {
          self.frame = CGRectMake(0, 436, 320, 44);
      
      }
      

      【讨论】:

        【解决方案4】:

        这里是快速版本:

        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)
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2022-09-22
          • 2020-01-29
          • 1970-01-01
          相关资源
          最近更新 更多