启用大标题时,当标题处于“小”状态时,视图的标题始终居中。我该如何改变?
我无法将自定义UILabel设置为titleView,因为使用此方法也会影响大标题。
所以我尝试了这个:
let paragraph = NSMutableParagraphStyle()
paragraph.alignment = .left
let attributes = [NSAttributedStringKey.foregroundColor:UIColor.black,
NSAttributedStringKey.paragraphStyle:paragraph]
self.navigationBar.titleTextAttributes = attributes
但不幸的是,这并不会影响标题在小状态下的排列。 (换色工作)
内部视图确实加载,创建具有所需属性的UILabel。然后像这样设置导航左栏按钮项
self.navigationItem.leftBarButtonItem = UIBarButtonItem(customView: myLabel)