Examples of Uinavigationcontroller and Uibarbuttonitem

Source: Internet
Author: User

#import "AppDelegate.h"

#import "FirstViewController.h"

#import "SecondViewController.h"

@interface Appdelegate ()

@end

@implementation Appdelegate

-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchOptions

{

Create a navigation bar view

Uinavigationcontroller *navc1=[[uinavigationcontroller Alloc] Initwithrootviewcontroller:[firstviewcontroller new] ];

Name of column

[Email protected] "message";

Prompt message

[Email protected] "2";

Add a picture

Navc1.tabbaritem.image=[uiimage imagenamed:@ "1"];

Uinavigationcontroller *navc2=[[uinavigationcontroller Alloc] Initwithrootviewcontroller:[secondviewcontroller New ]];

[Email protected] "dynamic";

[Email protected] "2";

Create columns

Uitabbarcontroller *tab=[[uitabbarcontroller alloc] init];

Add two navigation bars to the bottom view

[Email protected] [NAVC1,NAVC2];

Navc2.tabbaritem.image=[uiimage imagenamed:@ "2"];

Add foreground color

Tab.tabbar.tintcolor=[uicolor Greencolor];

Add the bottom view to the root view

Self.window.rootviewcontroller=tab;

return YES;

}

#import <UIKit/UIKit.h>

#import "SecondViewController.h"

@interface Firstviewcontroller:uiviewcontroller

@end

#import "FirstViewController.h"

@interface Firstviewcontroller ()

@end

@implementation Firstviewcontroller

-(void) viewdidload

{

[Super Viewdidload];

Replace background color

Self.view.backgroundcolor=[uicolor colorwithpatternimage:[uiimage imagenamed:@ "20141110_ F64c52ed5be2176adaa1madr4skv4nyu.jpg "];

Add title

[Email protected] "First view";

Change the foreground color of the title

[Email protected] {Nsforegroundcolorattributename:[uicolor Yellowcolor]};

Create a navigation bar button

Uibarbuttonitem *tab=[[uibarbuttonitem alloc] initwithtitle:@ "Next" Style:2 target:self action: @selector (next)];

Change the foreground color

Tab.tintcolor=[uicolor Redcolor];

Add Right button

Self.navigationitem.rightbarbuttonitem=tab;

}

-(void) Next

{

Secondviewcontroller *second=[[secondviewcontroller alloc] init];

Navigation bar View: Push to next page

[Self.navigationcontroller Pushviewcontroller:second Animated:yes];

}

#import "SecondViewController.h"

@interface Secondviewcontroller ()

@end

@implementation Secondviewcontroller

-(void) viewdidload

{

[Super Viewdidload];

Self.view.backgroundcolor=[uicolor colorwithpatternimage:[uiimage imagenamed:@ " 8efce6cd7b899e51feb2371b40a7d933c8950d83.jpg "];

[Email protected] "second view";

[Email protected] {Nsforegroundcolorattributename:[uicolor Greencolor]};

Uibarbuttonitem *tab=[[uibarbuttonitem alloc] initwithtitle:@ "Back" style:2 target:self action: @selector (BackPage)];

Self.navigationitem.leftbarbuttonitem=tab;

}

-(void) BackPage

{

Out of the stack to return to the previous page

[Self.navigationcontroller Popviewcontrolleranimated:yes];

}

Examples of Uinavigationcontroller and Uibarbuttonitem

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.