Remove text from Back button keeping the icon

前端 未结 29 2636
栀梦
栀梦 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-29 00:03

    I've tried a couple of answers and I can't get them to work in all cases. So this is a workaround to not affect the title of the navigation bar if it's set.

        guard let items = viewController.navigationController?.navigationBar.items else { return }
        for item in items {
            if item.title == nil {
                item.title = ""
            }
        }
    

提交回复
热议问题