UINavigationController标题与UIBarButton不对齐

时间:2019-05-27 01:23:41

标签: swift uinavigationcontroller uibarbuttonitem

我有一个UINavigationBar标题,可以通过在自定义self.title = "self.title"中调用UINavigationController来设置,并且BarButtonItem已安装在情节提要中。有谁知道这种错位的原因是什么,我将如何解决呢?通过调用以下命令设置标题字体大小:

self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 35),NSAttributedString.Key.foregroundColor: UIColor.white]

self.title is not lined up with UIBarButtonItem on the right

1 个答案:

答案 0 :(得分:0)

选中 UINavigationBar

的此方法
func setTitleVerticalPositionAdjustment(_ adjustment: CGFloat, 
                                for barMetrics: UIBarMetrics)

Apple Doc