How to change the uinavigationbar title's position?

前端 未结 4 422
广开言路
广开言路 2021-01-03 03:30

I\'ve managed to change the navigationbar height by using my own navigationbar, but the title is still centered. I want it to be at the 72px position from the left.

4条回答
  •  -上瘾入骨i
    2021-01-03 04:14

    Another solution is to simply indent the title:

    let paragraphStyle = NSMutableParagraphStyle()
    paragraphStyle.firstLineHeadIndent = 72
    
    navigationBar.titleTextAttributes = [
        .foregroundColor: UIColor.purple,
        .paragraphStyle: paragraphStyle
    ]
    

提交回复
热议问题