swift - Back Button Left Alignment IOS 9 -


i trying left align button i.e remove space on left of arrow . using custom button .

let backbutton = uibarbuttonitem(image: uiimage(named: "arrow03"), style: .plain, target: self, action: "back")  self.navigationcontroller?.navigationbar.tintcolor = uicolor.clearcolor() self.navigationitem.backbarbuttonitem = backbutton 

tried use negative width button suggested in below link didnt work. how edit empty spaces of left, right uibarbuttonitem in uinavigationbar [ios 7]

image

enter image description here

http://imgur.com/pa9hlbm

please help.

refer below code implement button on left alignment.

let button: uibutton = uibutton (type: uibuttontype.custom) button.setimage(uiimage(named: "imagename"), forstate: uicontrolstate.normal) button.addtarget(self, action: "backbuttonpressed:", forcontrolevents: uicontrolevents.touchupinside) button.frame = cgrectmake(0, 0, 30, 30) let barbutton = uibarbuttonitem(customview: button)  self.navigationitem.leftbarbuttonitem = barbutton 

note - make sure image has plain ( transparent ) background.

func backbuttonpressed(btn : uibutton) {      self.navigationcontroller?.popviewcontrolleranimated(true) } 

Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -