The theme is set, the code is initialized, and the corresponding navigation and Barbutton properties are set by executing the code.
/* * * */+ (void)initialize {// set properties for NAV. [self setnavigationbartheme]; // sets the properties of the Barbutton. [self setbarbuttontheme];}
setting of the corresponding attribute
+(void) setbarbuttontheme{//Uibarbuttonitem *appearence =[Uibarbuttonitem appearance]; Nsmutabledictionary*textattrs =[[Nsmutabledictionary alloc]init]; Textattrs[nsforegroundcolorattributename]=[Uicolor Orangecolor]; Textattrs[nsfontattributename]= [Uifont systemfontofsize: the]; [Appearence settitletextattributes:textattrs Forstate:uicontrolstatenormal]; Nsmutabledictionary*hightextattrs =[[Nsmutabledictionary alloc]init]; Hightextattrs[nsforegroundcolorattributename]=[Uicolor Redcolor]; Hightextattrs[nsfontattributename]= [Uifont systemfontofsize: the]; [Appearence settitletextattributes:hightextattrs forstate:uicontrolstatehighlighted]; Nsmutabledictionary*disabletextattrs =[[Nsmutabledictionary alloc]init]; Disabletextattrs[nsforegroundcolorattributename]=[Uicolor Graycolor]; Disabletextattrs[nsfontattributename]= [Uifont systemfontofsize: the]; [Appearence settitletextattributes:disabletextattrs forstate:uicontrolstatedisabled]; //to make the button's background disappear, you can set a completely transparent background image[Appearence setbackgroundimage:[uiimage imagenamed:@"Navigationbar_button_background"] Forstate:uicontrolstatenormal barmetrics:uibarmetricsdefault];}+(void) setnavigationbartheme{Uinavigationbar*appearence =[Uinavigationbar appearance]; Nsmutabledictionary*textattrs=[Nsmutabledictionary dictionary]; Textattrs[nsfontattributename]= [Uifont systemfontofsize: -]; Textattrs[nsforegroundcolorattributename]=[Uicolor Blackcolor]; [Appearence settitletextattributes:textattrs];}
Defined as a class method, easy to invoke.
The most important method is the overloaded push method
-(void) Pushviewcontroller: (Uiviewcontroller *) Viewcontroller animated: (BOOL) animated{if(self.viewcontrollers.count>0) {//If push comes in not a stack-bottom controller,viewcontroller.hidesbottombarwhenpushed =YES; ViewController.navigationItem.leftBarButtonItem= [Uibarbuttonitem itemwithimage:@"Navigationbar_back"Highimage:@"navigationbar_back_highlighted"target:self Action: @selector (back)]; ViewController.navigationItem.rightBarButtonItem= [Uibarbuttonitem itemwithimage:@"Navigationbar_more"Highimage:@"navigationbar_more_highlighted"target:self Action: @selector (more)]; } [Super Pushviewcontroller:viewcontroller animated:yes];}
Push to set the corresponding properties, including the corresponding background and highlight the background click Time corresponding to the response function.
Sets the response content of the corresponding button click.
-(void) more
{
[Self poptorootviewcontrolleranimated:yes];
}
-(void) back
{
[Self popviewcontrolleranimated:yes];
}
Code Building Notepad Framework (ii)