swift - change uinavigation bar item position -
for need create custom barbuttonitem
, set right side, need hide default backbarbutton
, try thing this. add below code inside viewdidload
.
self.navigationitem.hidesbackbutton = true let btnforward = uibutton(frame: cgrect(x: 0, y: 0, width: 25, height: 25)) btnforward.setimage(uiimage(named: "forward_arrow"), forstate: .normal) btnforward.addtarget(self, action: #selector(self.buttonaction(_:)), forcontrolevents: .touchupinside) let backitem = uibarbuttonitem(customview: btnforward) self.navigationitem.rightbarbuttonitem = backitem
after add action method inside viewcontroller
func buttonaction(sender: uibutton) { self.navigationcontroller?.popviewcontrolleranimated(true) }
Comments
Post a Comment