The code controls the left and right item:
UIButton *btncancel = [UIButton buttonwithtype:uibuttontypecustom]; btncancel.frame=cgrectmake (0, 0, 60, 3 0); btncancel.titlelabel.font=[uifont systemfontofsize:13]; Btncancel.contenthorizontalalignment = uicontrolcontenthorizontalalignmentleft; [BtnCancel setTitle:@] Back to "forstate:uicontrolstatenormal]; [btncancel addtarget:self action: @selector (Buttoncancel:) forcontrolevents:uicontroleventtouchupinside]; self.navigationitem.leftbarbuttonitem=[[ Uibarbuttonitem Alloc] initwithcustomview:btncancel]; UIButton *btncommit = [UIButton buttonwithtype:uibuttontypecustom]; Btncommit.frame=cgrectmake (0, 0, max); Btncommit.titlelabel.font=[uifont systemfontofsize:13]; Btncommit.contenthorizontalalignment = uicontrolcontenthorizontalalignmentright; [Btncommit settitle:@ "submit" forstate:uicontrolstatenormal]; [Btncancel addTarget:self Action: @selector (commitaction:) forcontrolevents:uicontroleventtouchupinside]; Self.navigationitem.rightbarbuttonitem=[[uibarbuttonitem alloc] initwithcustomview:btncommit];
Other methods:
The first type: This setting out of the appearance of bad control UIImage *searchimage=[uiimage imagenamed:@ "Search.png"]; Uibarbuttonitem *barbtn=[[uibarbuttonitem alloc] Initwithimage:nil style:uibarbuttonitemstyledone target:self action : @selector (Searchprogram)]; Barbtn.image=searchimage; self.navigationitem.rightbarbuttonitem=barbtn;//Second type: This picture will fill the button, the size controllable Uibutton*rightbutton = [[UIButton alloc] Initwithframe:cgrectmake (0,0,30,30)]; [Rightbutton setimage:[uiimage imagenamed:@ "Back.png"]forstate:uicontrolstatenormal]; [Rightbutton addtarget:self Action: @selector (Backto) forcontrolevents:uicontroleventtouchupinside]; Uibarbuttonitem*rightitem = [[Uibarbuttonitem Alloc]initwithcustomview:rightbutton]; Self.navigationitem.leftbarbuttonitem= Rightitem; The Third Kind: uibarbuttonitem *anotherbutton = [[Uibarbuttonitem alloc] Initwithbarbuttonsystemitem: Uibarbuttonsystemitembookmarks target:self Action: @selector (Methodtocall:)]; How to make Navigationitem.rightbarbuttonitem hide away? Self.navigationitem.rightbarbuttonitem=nil; can be achieved
Navigate VC's left and right item code