1. Custom Navigationcontroller:
@interface Customnavigationcontroller:uinavigationcontroller
2. override the Push method to intercept the push-in controller :
- (void) Pushviewcontroller: (Uiviewcontroller *) Viewcontroller animated: (BOOL) animated{//determine if the controller that the push comes in is the root controller if(Self.childViewControllers.count >0) { //Hide Tabbarbottom when push (application hierarchy Tabbarcontroller-Navigationcontroller)viewcontroller.hidesbottombarwhenpushed =YES; //add left item to NavigationitemViewController.navigationItem.leftBarButtonItem = [Uibarbuttonitem itemwithtarget:self image:@ "Leftbarbuttonimage"highlightedimage:@"leftbarbuttonimage_highlighted"Action: @selector (Clickleftitem)]; //add left item to NavigationitemViewController.navigationItem.rightBarButtonItem = [Uibarbuttonitem itemwithtarget:self image:@] Rightbarbuttonimage"highlightedimage:@ "rightbarbuttonimage_highlighted"Action: @selector (Clickrightitem)]; } [Super Pushviewcontroller:viewcontroller Animated:yes]; }
Item Click event:
-(void) clickleftitem{ // Method [self Popviewcontrolleranimated:yes];}
-(void) clickleftitem{ // Method}
3. By Category, customize the Barbuttonitem creation method:
/** * Create Item * * @param imageName Item picture * @param highlightedimagename Item's highlighted picture * @param Target Item Click event Performer * @param action Item Click event * */+ (Uibarbuttonitem *) Itemwithtarget: (ID) Target Image: ( NSString *) ImageName highlightedimage: (NSString *) highlightedimagename action: (SEL) action{ //Create button UIButton *button = [UIButton buttonwithtype:uibuttontypecustom]; Set button picture [button setimage:[uiimage Imagenamed:imagename] forstate:uicontrolstatenormal]; [Button Setimage:[uiimage Imagenamed:highlightedimagename] forstate:uicontrolstatehighlighted]; Set Button size button.size = button.currentImage.size;//Avoid picture stretching //Setting button listening events [button Addtarget:target action : Action Forcontrolevents:uicontroleventtouchupinside]; return item return [[Uibarbuttonitem alloc] Initwithcustomview:button];}
IOS Navigation Custom Settings item