如何更改导航栏Swift 3的高度 [英] How can I change height of Navigation Bar Swift 3
问题描述
我很确定这不是重复的,因为我查看了其他答案,它们都已过时,并没有提供确切的答案。
I'm pretty sure this is not duplicate because I looked at other answers and they all outdated and do not provide exact answer.
我有导航控制器和几个视图控制器。我想让导航栏更高一些,所以它适合我需要的文本大小。我怎样才能做到这一点 ?
I have Navigation Controller and several view controllers. I want to make Navigation Bar a bit taller so it would fit text size that I need. How can I do that ?
我试过这个:
UINavigationBar.appearance()。frame = CGRect(x:0.0,y:0.0,width:320.0,height:210.0)但是没有任何反应...
I tried this: UINavigationBar.appearance().frame = CGRect(x: 0.0, y: 0.0, width: 320.0, height: 210.0) but nothing happens...
此外,我无法使用Xcode布局按钮向导航栏添加任何约束。
Also, I wasn't able to add any constraints to the Nav Bar using Xcode layout buttons.
希望有人能帮助我解决这个问题。提前致谢!
Hope somebody can help me to fix this issue. Thanks in advance!
推荐答案
这是一种方法:
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let height: CGFloat = 50 //whatever height you want to add to the existing height
let bounds = self.navigationController!.navigationBar.bounds
self.navigationController?.navigationBar.frame = CGRect(x: 0, y: 0, width: bounds.width, height: bounds.height + height)
}
这篇关于如何更改导航栏Swift 3的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!