我想居中两个导航项目,以便它们与导航栏标题视图垂直对齐。如何居中导航栏的导航项目?
这是相当简单的居中导航控制器的导航栏标题视图(该代码属于导航控制器自定义类):
override func viewDidLoad() {
super.viewDidLoad()
self.navigationBar.setTitleVerticalPositionAdjustment(-8, for: .default)
}
但这代码不居中导航项目:
let menuButton = UIBarButtonItem(image: #imageLiteral(resourceName: "menu"), style: .plain, target: self, action: #selector(handleLogout))
menuButton.tintColor = UIColor(r: 149, g: 156, b: 151)
self.navigationItem.leftBarButtonItem = menuButton
UIButtonItem
都不具备的框架性质,我也可以使用自动布局。我怎样才能集中我的导航项目?
劈:http://stackoverflow.com/questions/39931976/how-to-get-uibarbuttonitem-center-position – shallowThought