Code Building Notepad Framework (ii)

Source: Internet
Author: User

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.