我需要调整我的UIBarButtonItems的垂直位置。 我似乎能够为标题做得很好,但按钮似乎不适合它。我究竟做错了什么?
var leftBarButtonItem : UIBarButtonItem?
leftBarButtonItem
= UIBarButtonItem(title: "", style: .done, target: self, action: #selector(self.leftBarButtonPressed(_:)))
leftBarButtonItem?.image = UIImage(named: "menu_ic")
self.navigationItem.leftBarButtonItem = leftBarButtonItem
self.navigationController?.navigationItem.leftBarButtonItem?.setBackgroundVerticalPositionAdjustment(CGFloat(18), for: UIBarMetrics.default)
var rightBarButtonItem : UIBarButtonItem?
rightBarButtonItem
= UIBarButtonItem(title: "MAP", style: .done, target: self, action:
#selector(self.rightBarButtonPressed(_:)))
self.navigationItem.rightBarButtonItem = rightBarButtonItem
let height: CGFloat = 60 //sets height of UINavigationBar
let bounds = self.navigationController!.navigationBar.bounds
self.navigationController?.navigationBar.frame = CGRect(x: 0, y: 0, width: bounds.width, height: bounds.height + height)
self.navigationController!.navigationBar.setTitleVerticalPositionAdjustment(CGFloat(18), for: UIBarMetrics.default)