eve*_*erk 6 uinavigationbar uinavigationcontroller uinavigationitem swift ios11
是否可以更改大导航栏标题的x偏移?我想将x偏移更改为36pt。
TiM*_*TiM 12
I just discovered in the latest version of iOS 12, if you simply modify the layoutMargins property of the UINavigationBar, this will affect the large title.
let navigationBar = navigationController.navigationBar
navigationBar.layoutMargins.left = 36
navigationBar.layoutMargins.right = 36
Run Code Online (Sandbox Code Playgroud)
I tried the solution mentioned here about using a custom NSMutableParagraphStyle. That does indeed work, but because it stretches the UILabel view that the large title is made of, when you swipe downwards, the subtle animation it plays where the text grows slightly becomes quite distorted.
小智 6
您可以通过以下方式添加其他偏移量:
if #available(iOS 11.0, *) {
let navigationBarAppearance = UINavigationBar.appearance()
let style = NSMutableParagraphStyle()
style.alignment = .justified
style.firstLineHeadIndent = 18
navigationBarAppearance.largeTitleTextAttributes = [NSAttributedStringKey.paragraphStyle: style]
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1728 次 |
| 最近记录: |