无法在NavigationController中更改NavigationBar的高度(比正常情况宽得多) [英] Can't Change Height of NavigationBar in NavigationController (it's much wider than normal)

查看:108
本文介绍了无法在NavigationController中更改NavigationBar的高度(比正常情况宽得多)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个从主TabBarController扩展到一个ViewController的NavigationController,并且VC扩展到2x TableView(所以,TabBar-> NavigationController-> ViewController-> 2xTableView [with .xib]).我必须将导航栏添加到导航控制器中才能使其在viewController中工作,从而可以在两个表视图中使用(因为我使用 PageMenu ,将PageMenuDemoSegmentedControlGif.gif"rel =" nofollow noreferrer> Instagram式滑动 ).现在,我可以看到导航栏. (请注意,我必须在Storyboard的导航栏上取消选中Translucent才能使其可见)

但是,它很宽,因此我正在尝试缩小高度.我已经尝试了网上找到的几个答案,但对我来说却不走运.首先,我尝试将约束添加到导航栏(在NavCont中),但是,当我单击约束时,所有内容都被禁用(...但是,例如,当我从情节提要中更改导航栏的颜色时,它可以工作.)

此外,在我的ViewController中(我链接到TableView的地方使用此代码),因此我可以使用它们并自定义导航栏,但是当我尝试

// These works
self.title = "GLOBAL"      
self.navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.blackColor()]

// Neither works for Height
self.navigationController?.navigationBar.frame.size.height = 200
self.navigationController?.navigationBar.frame = CGRectMake(0, 0, 320, 64)
self.navigationController?.navigationBar.frame.origin.y = -50

我想要实现的导航栏的高度(对于另一个UIView,只需拖动导航栏以在Storyboard上查看即可实现):

这是它的样子

解决方案

只需拖动导航栏以在情节提要板上查看即可实现另一个UIView

是的,但这就是区别-世界上所有的区别.您可以通过您的导航栏执行任何所需的操作.但是,UINavigationController拥有和出售的导航栏的高度取决于您.它不是您的导航栏,您应该放弃改变其大小的所有希望.导航控制器由您负责,而不是您.

I have a NavigationController extending from a master TabBarController and extending a ViewController and VC extends to 2x TableView (so, TabBar -> NavigationController -> ViewController -> 2xTableView[with .xib] ). I had to add Navigation Bar to the Navigation Controller to make it work in the viewController, thus works in both tableviews (because I use Instagram-style swipe by using PageMenu). Now, I can see the navigation bar. (Please note that I had to uncheck Translucent on navigation bar on Storyboard to make it visible)

However, it's quite wide, so I am trying to narrow the height. I have tried several answers that I've found online, but no luck for me. First, I tried adding constraints to Navigation Bar (in NavCont) but, when I click on the constraints, everything is disabled (...but for example, when I change the colour of Navigation Bar from storyboard, it works.)

Also, in my ViewController (where I link to TableView using this code), so I can use these and customise Navigation Bar, however when I try

// These works
self.title = "GLOBAL"      
self.navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.blackColor()]

// Neither works for Height
self.navigationController?.navigationBar.frame.size.height = 200
self.navigationController?.navigationBar.frame = CGRectMake(0, 0, 320, 64)
self.navigationController?.navigationBar.frame.origin.y = -50

The height of Navigation Bar I want to achieve (and achieved for another UIView, by simply dragging Navigation bar to view on Storyboard):

This is how it looks

解决方案

achieved for another UIView, by simply dragging Navigation bar to view on Storyboard

Yes, but that's the difference - all the difference in the world. You can do anything you want with your navigation bar. But the height of the navigation bar owned and vended by a UINavigationController is not up to you. It is not your navigation bar and you should abandon all hope of changing its size; the navigation controller is in charge, not you.

这篇关于无法在NavigationController中更改NavigationBar的高度(比正常情况宽得多)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆