ios - How can I set a logo in the navigation bar for all view controllers from a central place -


how can set logo in navigation bar view controllers central place? mean, wouldn't set logo in code of every view controller (viewdidload()) method. there place put that, appdelegate or event fired after every screen change? put code below in appdelegate worked initial screen. thanks.

    let img = uiimageview(image: uiimage(named: "tourney"))     img.contentmode = .scaleaspectfit      let logo =  uibarbuttonitem(customview: img)      let root = window?.rootviewcontroller!     root?.childviewcontrollers[0].childviewcontrollers[0].navigationitem.rightbarbuttonitem = logo 

extension uiviewcontroller , adding method setupnavigationbar setup navigation center image .

extension uiviewcontroller {      func setupnavigationbar(image: uiimage) {         //set image navigation bar center         //set titile         //self.navigationitem.title =  title          //set image in center           self.navigationitem.titleview = uiimageview(image: image)     } } 

now setupnavigationbar viewcontroller , try call way

 override func viewdidload() {         super.viewdidload()          self.setupnavigationbar(image: uiimage(named: "tourney")) } 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -