Lal*_*hna 5 ios swift preferslargetitles ios13
我正在尝试设计具有多行居中大标题文本的视图控制器,就像苹果的 Ask Siri ( Settings->General->Keyboards->About Ask Siri, Dictation and Privacy...) 一样。
我可以使用以下方法实现居中文本:
let paragraph = NSMutableParagraphStyle()
paragraph.alignment = .center
navigationController?.navigationBar.largeTitleTextAttributes = [.paragraphStyle: paragraph]
Run Code Online (Sandbox Code Playgroud)
我确实从情节提要中设置了导航标题,并尝试了这些来实现多行大标题:
但它们都不适用于 iOS 13。
bes*_*per -2
没有任何此类属性可以设置并title成为多行。你需要操纵它。
这是如何创建多行导航栏标题的代码示例:
label.backgroundColor = .clear
label.numberOfLines = 2
label.font = UIFont.boldSystemFont(ofSize: 16.0)
label.textAlignment = .center
label.textColor = .white
label.text = "This is a\nmultiline string for the navBar"
self.navigationItem.titleView = label```
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
963 次 |
| 最近记录: |