How to Change back button title on navigation controller in swift3?

后端 未结 8 583
天命终不由人
天命终不由人 2020-12-06 18:54

I want to change the title of backbutton to any name in swift 3.I tried many ways but none of them worked for me.

self.navigationItem.backBarButtonItem?.titl         


        
8条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-06 19:31

    In Swift 3.0 put below code in appdelegate didFinishLaunchingWithOptions method its worked perfectly for me

    let backImage = UIImage(named: "BackNavigation")?.withRenderingMode(.alwaysOriginal)
    UINavigationBar.appearance().backIndicatorImage = backImage
    UINavigationBar.appearance().backIndicatorTransitionMaskImage = backImage
    UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment(UIOffsetMake(0, -80.0), for: .default)
    

    The last line will remove the title of Navigation Back Button if you don't want to remove title then just comment it

提交回复
热议问题