我很确定这不是重复的,因为我查看了其他答案,但它们都已过时且未提供确切答案。
我有导航 Controller 和几个 View Controller 。我想让 Navigation Bar 高一点,以便它适合我需要的文本大小。我怎样才能做到这一点 ?
我试过这个:
UINavigationBar.appearance().frame = CGRect(x: 0.0, y: 0.0, width: 320.0, height: 210.0)
但是什么也没发生...
此外,我无法使用 Xcode 布局按钮向导航栏添加任何约束。
希望有人能帮我解决这个问题。提前致谢!
最佳答案
2020 年 8 月 3 日更新:我在 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)
}
关于ios - 如何更改导航栏的高度 - Swift 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40751366/