ios - Positioning image of navigationBar backButton -


i add image navigation controller button this:

self.navigationitem.backbarbuttonitem = [[uibarbuttonitem alloc] initwithimage:[uiimage imagenamed:@"itbutton.png"] style:uibarbuttonitemstylebordered target:nil action:nil]; 

it works fine, therefore, image not aligned < symbol. image little above symbol, want both centered. don't know why. i've tried adjust using:

[self.navigationitem.backbarbuttonitem setimageinsets:uiedgeinsetsmake(10, 0, 0, 0)]; 

but nothing changed.

there many ways fix issue, facing same issue have solved way

-(void)viewwillappear:(bool)animated {     [super viewwillappear:animated];     if([self.navigationcontroller.viewcontrollers objectatindex:0] != self)     {         uibutton *backbutton = [[uibutton alloc] initwithframe:cgrectmake(0, 0, 26, 26)];         [backbutton setimage:[uiimage imagenamed:@"home.png"] forstate:uicontrolstatenormal];         [backbutton setshowstouchwhenhighlighted:true];         [backbutton addtarget:self action:@selector(popviewcontrollerwithanimation) forcontrolevents:uicontroleventtouchdown];         uibarbuttonitem *barbackitem = [[uibarbuttonitem alloc] initwithcustomview:backbutton];         self.navigationitem.hidesbackbutton = true;         self.navigationitem.leftbarbuttonitem = barbackitem;      } }  -(void)popviewcontrollerwithanimation {     [self.navigationcontroller popviewcontrolleranimated:yes];  } 

Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -