如何更改导航栏的高度-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)
但没有任何反应...
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!
推荐答案
更新8/3/20:我在2016年发布了此内容.许多人表示此功能不再有效,请您自担风险.我目前不在iOS系统中工作,因此没有可用的更新程序.祝你好运!
这是一种实现方法:
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屋!