How can you customize the return keys in the navigation controller all at once.
Ideas:
We can set this custom button on push, and push has a method
-(void) Pushviewcontroller: (Uiviewcontroller *) Viewcontroller animated: (BOOL) animated{}
In this method Viewcontroller is the object of the push
But to determine if this Viewcontroller is a root controller,
-(void) Pushviewcontroller: (uiviewcontroller *) Viewcontroller animated: (BOOL) animated{
If(Self. childviewcontrollers. Count > 0) { // non-root controller
//The non-root controller needs to set the return button
//Set Back button
UIButton*backbutton = [UIButtonButtonwithtype:Uibuttontypecustom];
[BackbuttonSettitle:@"Return"Forstate:UIControlStateNormal];
[BackbuttonSetImage:[UIImageImagenamed:@ "Navigationbuttonreturn"]Forstate:UIControlStateNormal];
[BackbuttonSetImage:[UIImageImagenamed:@ "Navigationbuttonreturnclick"]Forstate:uicontrolstatehighlighted];
[BackbuttonSettitlecolor:[UicolorBlackcolor]Forstate:UIControlStateNormal];
[BackbuttonSettitlecolor:[UicolorRedcolor]Forstate:uicontrolstatehighlighted];
[BackbuttonAddTarget:SelfAction:@selector(back)forControlEvents:UIControlEventTouchUpInside];
[BackbuttonSizeToFit];
//Attention:Be sure to have the button content in a size,The setting is only effective
Backbutton.Contentedgeinsets=Uiedgeinsetsmake(0, -25,0,0);
//Set Back button
Viewcontroller.Navigationitem.Leftbarbuttonitem= [[UibarbuttonitemAlloc]Initwithcustomview: Backbutton];
}
This is the way to actually perform a jump
[Super Pushviewcontroller: Viewcontroller animated: animated];
}
How to set a custom navigation controller global return button---iOS