使用大型标题时如何对齐左侧的导航标题?

问题描述 投票:1回答:1

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

我无法将自定义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个回答
-1
投票

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

self.navigationItem.leftBarButtonItem = UIBarButtonItem(customView: myLabel)
© www.soinside.com 2019 - 2024. All rights reserved.