Remove text from Back button keeping the icon

前端 未结 29 2662
栀梦
栀梦 2020-11-28 23:26

I want to remove the text from the back button, but I want to keep the icon. I have tried

let backButton = UIBarButtonItem(title: \"\", style: UIBarButtonIt         


        
29条回答
  •  爱一瞬间的悲伤
    2020-11-28 23:52

    In my case, for custom icon and title this did the trick (Swift 4)

        let imgBack = UIImage(named: "ic_back")
    
        navigationController?.navigationBar.backIndicatorImage = imgBack
        navigationController?.navigationBar.backIndicatorTransitionMaskImage = imgBack
    
        navigationItem.leftItemsSupplementBackButton = true
        navigationController?.navigationBar.topItem?.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: self, action: nil)
    

提交回复
热议问题