我設法增加了我的導航欄的高度,但是我遇到了問題,那個標題和按鈕位於導航欄的底部。垂直中心導航欄視圖
extension UINavigationBar {
open override func sizeThatFits(_ size: CGSize) -> CGSize {
let v = self.value(forKey: "frame") as? CGRect
return v?.size ?? CGSize(width: UIScreen.main.bounds.width, height: 44)
}
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationBar.frame = CGRect(x: 0, y: 0, width: bounds.width, height: 64)
}
我試圖設置偏移,使用
navigationBar.setTitleVerticalPositionAdjustment(-10, for: .default)
navigationItem.leftBarButtonItem?.setBackgroundVerticalPositionAdjustment(-10, for: .default)
navigationItem.rightBarButtonItem?.setBackgroundVerticalPositionAdjustment(-10, for: .default)
navigationItem.rightBarButtonItem?.setBackButtonBackgroundVerticalPositionAdjustment(-10, for: .default)
navigationItem.leftBarButtonItem?.setBackButtonBackgroundVerticalPositionAdjustment(-10, for: .default)
其實,設置只適用於我的頭銜,以及按鈕欄的位置保持不變。
但我不認爲我的解決方案是最好的。
你爲什麼不展示你究竟是如何增加導航欄高度的? –
有關此問題的評論中的夫婦鏈接可能會有所幫助:https://stackoverflow.com/questions/44181264/move-navigationbars-left-and-right-barbuttonitems-vertically-upwards – DonMag