ios - How to create custom back button for use with nav bar and subviews -


i have main view controller tableview , detail view controller display details selected item. have nav bar inserts button when user segues detail screen. on detail screen, have container view can show other view controllers on bottom half of screen. when user brings subview, want replace standard button custom button resigns subview, not going main view controller. once subview gone, button should revert stock button go main view controller when pressed.

my issue i'm having trouble making buttons appear same user doesn't know i'm using different buttons achieve these different things. best way this? can't text match up, image better way go?

currently in prepareforsegue in main view controller:

// setting nav button text "<" default when no text       let backitem = uibarbuttonitem()       backitem.title = ""       navigationcontroller?.navigationbar.tintcolor = uicolor.whitecolor()       navigationitem.backbarbuttonitem = backitem 

currently in detail view controller:

func createcustombackbutton() {        self.navigationitem.hidesbackbutton = true        let customfont = uifont(name: "helveticaneue", size: 30.0)!       uibarbuttonitem.appearance().settitletextattributes([nsfontattributename: customfont], forstate: uicontrolstate.normal)        custombackbutton = uibarbuttonitem(title: "<", style: .plain, target: self, action: "back:")       self.navigationitem.leftbarbuttonitem = custombackbutton    } 

any appreciated, in advance!!

so short answer have create own button

   self.navigationitem.hidesbackbutton = true;   self.navigationitem.leftbarbuttonitem = //your custom bar button item 

alternatively can piggy on default ios button out on head

by setting title "" , setting indicator image

    self.backindicatorimage = backbuttonicon.image     self.backindicatortransitionmaskimage = backbuttonicon.image 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -