ios - reduce left space and right space from navigation bar left and right bar button item -
i adding 2 custom buttons on navigation bar. 1 @ left , other @ right. done it,
but failed reduce space between starting point , frame of buttons.
i tried lot, gave negative value of x, still didn't helped. here code buttons
-(void)addleftbutton { uibutton *abutton = [uibutton buttonwithtype:uibuttontypecustom]; abutton.backgroundcolor = [uicolor redcolor]; [abutton settitle:@"h" forstate:uicontrolstatenormal]; abutton.frame = cgrectmake(0.0, 0.0, 40, 40); [abutton settitlecolor:[uicolor blackcolor] forstate:uicontrolstatenormal]; uibarbuttonitem *abarbuttonitem = [[uibarbuttonitem alloc] initwithcustomview:abutton]; [abutton addtarget:self action:@selector(backbtnclicked:) forcontrolevents:uicontroleventtouchupinside]; [self.navigationitem setleftbarbuttonitem:abarbuttonitem]; } -(void)addrightbutton { uibutton *abutton = [uibutton buttonwithtype:uibuttontypecustom]; abutton.backgroundcolor = [uicolor greencolor]; [abutton settitle:@"b" forstate:uicontrolstatenormal]; abutton.frame = cgrectmake(0.0, 0.0, 40, 40); [abutton settitlecolor:[uicolor blackcolor] forstate:uicontrolstatenormal]; uibarbuttonitem *abarbuttonitem = [[uibarbuttonitem alloc] initwithcustomview:abutton]; [abutton addtarget:self action:@selector(backbtnclicked:) forcontrolevents:uicontroleventtouchupinside]; [self.navigationitem setrightbarbuttonitem:abarbuttonitem]; }
also tried using
abarbuttonitem.width = -16;
but didn't helped.
how achieve this...? in advance...
these links preferred didn't helped how edit empty spaces of left, right uibarbuttonitem in uinavigationbar [ios 7]
how edit empty spaces of left, right uibarbuttonitem in uinavigationbar [ios 7]
uibarbuttonitem *negativespacer = [[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemfixedspace target:nil action:nil]; negativespacer.width = -16; [self.navigationitem setleftbarbuttonitems:[nsarray arraywithobjects:negativespacer,yourbutton, nil] animated:yes];
use that.
Comments
Post a Comment