无法更改 NavigationController 中 NavigationBar 的高度(它比正常情况宽得多)
Can't Change Height of NavigationBar in NavigationController (it's much wider than normal)
我有一个 NavigationController 从主 TabBarController 扩展并扩展 ViewController 和 VC 扩展到 2x TableView(所以,TabBar -> NavigationController -> ViewController -> 2xTableView[与.xib])。我必须将导航栏添加到导航控制器以使其在 viewController 中工作,因此在两个表视图中工作(因为我使用 Instagram-style swipe by using PageMenu)。现在,我可以看到导航栏了。 (请注意,我必须取消选中 Storyboard 导航栏上的 Translucent
才能使其可见)
但是,它很宽,所以我正在尝试缩小高度。我已经尝试了几个我在网上找到的答案,但对我来说没有运气。首先,我尝试向导航栏添加约束(在 NavCont 中)但是,当我单击约束时,所有内容都被禁用(......但是例如,当我从情节提要中更改导航栏的颜色时,它起作用了。)
此外,在我的 ViewController 中(我 link 到 TableView using this code),所以我可以使用这些并自定义导航栏,但是当我尝试
// 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上查看):
这是它的样子
achieved for another UIView, by simply dragging Navigation bar to view on Storyboard
是的,但这就是区别 - 世界上所有的区别。您可以使用您的 导航栏做任何您想做的事情。但是 UINavigationController 拥有和提供的导航栏的高度不由您决定。它不是你的导航栏,你应该放弃改变它大小的所有希望;导航控制器负责,而不是你。
我有一个 NavigationController 从主 TabBarController 扩展并扩展 ViewController 和 VC 扩展到 2x TableView(所以,TabBar -> NavigationController -> ViewController -> 2xTableView[与.xib])。我必须将导航栏添加到导航控制器以使其在 viewController 中工作,因此在两个表视图中工作(因为我使用 Instagram-style swipe by using PageMenu)。现在,我可以看到导航栏了。 (请注意,我必须取消选中 Storyboard 导航栏上的 Translucent
才能使其可见)
但是,它很宽,所以我正在尝试缩小高度。我已经尝试了几个我在网上找到的答案,但对我来说没有运气。首先,我尝试向导航栏添加约束(在 NavCont 中)但是,当我单击约束时,所有内容都被禁用(......但是例如,当我从情节提要中更改导航栏的颜色时,它起作用了。)
此外,在我的 ViewController 中(我 link 到 TableView using this code),所以我可以使用这些并自定义导航栏,但是当我尝试
// 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上查看):
这是它的样子
achieved for another UIView, by simply dragging Navigation bar to view on Storyboard
是的,但这就是区别 - 世界上所有的区别。您可以使用您的 导航栏做任何您想做的事情。但是 UINavigationController 拥有和提供的导航栏的高度不由您决定。它不是你的导航栏,你应该放弃改变它大小的所有希望;导航控制器负责,而不是你。