【问题标题】:How to align the Navigation Title the left when using large Titles?使用大标题时如何将导航标题左对齐?
【发布时间】:2019-02-06 08:28:07
【问题描述】:

启用大标题时,当标题处于“小”状态时,视图的标题始终居中。我该如何改变?

我无法将自定义 UILabel 设置为 titleView,因为这种方法也会影响大标题。

所以我尝试了这个:

let paragraph = NSMutableParagraphStyle()
paragraph.alignment = .left
let attributes = [NSAttributedStringKey.foregroundColor:UIColor.black,
                  NSAttributedStringKey.paragraphStyle:paragraph]
self.navigationBar.titleTextAttributes = attributes

但不幸的是,这根本不会影响标题在其小状态下的对齐方式。 (换色有效)

【问题讨论】:

标签: ios swift uinavigationcontroller alignment nsattributedstring


【解决方案1】:

内部视图确实加载了,创建了一个具有所需属性的 UILabel。 然后像这样设置导航左栏按钮项

self.navigationItem.leftBarButtonItem = UIBarButtonItem(customView: myLabel)

【讨论】:

  • 这不起作用,因为当大标题处于活动状态时,“按钮”也在那里。
猜你喜欢
  • 2021-05-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-01-10
  • 2018-04-16
  • 1970-01-01
  • 2017-12-08
  • 1970-01-01
相关资源
最近更新 更多