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
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
Post a Comment