Change color and back button title of Navigation Bar from Swift 3 code

浪尽此生 提交于 2020-12-12 11:48:12

问题


Making UI of my app using code only. Can't find how customize couple elements: 1. Button 'Back' now it looks like:

and it should looks like:

So, how I can get rid of 'Back' text from button title, keeping '<' system icon there? And how I can change colors of back button and title of navigation bar?


回答1:


try

    self.navigationController?.navigationBar.tintColor = UIColor.white



回答2:


Try:

override func viewDidLoad(){
    //any other initial stuffs

    //for the bar
    navigationController?.navigationBar.tintColor = UIColor.black
    //for the button
    navigationController?.navigationBar.backItem?.titleView?.tintColor = UIColor.white
}



回答3:


Follow the instruction from your xcode. You can do this easily. I also marked on the image . Select 1. Select the Standard Editor, 2. Show the File inspector 3 Set global Ting



来源:https://stackoverflow.com/questions/40958996/change-color-and-back-button-title-of-navigation-bar-from-swift-3-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!