Is it possible to change the x-offset of the large navigation bar title? I would like to change the x-offset to 36pt.
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
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.
You can add additional offset this way:
if #available(iOS 11.0, *) {
let navigationBarAppearance = UINavigationBar.appearance()
let style = NSMutableParagraphStyle()
style.alignment = .justified
style.firstLineHeadIndent = 18
navigationBarAppearance.largeTitleTextAttributes = [NSAttributedStringKey.paragraphStyle: style]
}
You can't. You need to write your own NavigationController, by subclassing the UINavigationController for that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With