【问题标题】:UINavigationController title not aligned with UIBarButtonUINavigationController 标题未与 UIBarButton 对齐
【发布时间】:2019-05-27 01:23:40
【问题描述】:

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

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

【问题讨论】:

  • 错位在哪里?
  • @ShauketSheikh 我想要的对齐方式是 title 和 barbutton 匹配的 centerY,但目前两者的底部相互对齐。如何将其更改为 centerY 对齐?
  • 您是否使用图像作为条形按钮?如果您正在使用然后更改图像的大小并再次放在那里它将被对齐

标签: swift uinavigationcontroller uibarbuttonitem


【解决方案1】:

勾选UINavigationBar

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

Apple Doc

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-12
    • 1970-01-01
    • 2016-06-11
    • 1970-01-01
    • 2017-08-05
    相关资源
    最近更新 更多