//
**创建三个控制器 要求 :
1.命名 First ~ Third。 2.分别设置背景颜⾊色红、灰、蓝。 3.如⽰示例完成⾃自定义导航栏。**

//
// AppDelegate.h
// UI7_作业
//
// Created by YIem on 15/12/15.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//

import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (retain, nonatomic) UIWindow *window;

@end


//
// AppDelegate.m
// UI7_作业
//
// Created by YIem on 15/12/15.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//

import "AppDelegate.h"

import "RootViewController.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

  • (void)dealloc
    {
    [_window release];
    [super dealloc];
    }
  • (BOOL)application:(UIApplication )application didFinishLaunchingWithOptions:(NSDictionary )launchOptions {
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];

    RootViewController *rootVC = [[RootViewController alloc]init];
    UINavigationController *navi = [[UINavigationController alloc]initWithRootViewController:rootVC];
    self.window.rootViewController = navi;
    [navi release];
    [rootVC release];

    [_window release];
    return YES;
    }

  • (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
    }
  • (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
    }
  • (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
    }
  • (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    }
  • (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
    }

@end



//
// RootViewController.h
// UI7_作业
//
// Created by YIem on 15/12/15.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//

import <UIKit/UIKit.h>

@interface RootViewController : UIViewController

@end


//
// RootViewController.m
// UI7_作业
//
// Created by YIem on 15/12/15.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//

import "RootViewController.h"

import "Root1ViewController.h"

@interface RootViewController ()

@end

@implementation RootViewController

  • (void)viewDidLoad {

    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor redColor];
    // 第一
    self.title = @"第一页";
    self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"1"] style:UIBarButtonItemStylePlain target:self action:@selector(left)] autorelease];
    self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"2"] style:UIBarButtonItemStylePlain target:self action:@selector(right)] autorelease];
    
    
    
    

    }

  • (void)left
    {

    }

  • (void)right
    {

    Root1ViewController *rootVC = [[Root1ViewController alloc]init];
    [self.navigationController pushViewController:rootVC animated:YES];
    [rootVC release];

    }

  • (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.

    }

/*

pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation

  • (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.

    }

*/

@end



//
// Root1ViewController.h
// UI7_作业
//
// Created by YIem on 15/12/15.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//

import <UIKit/UIKit.h>

@interface Root1ViewController : UIViewController

@end


//
// Root1ViewController.m
// UI7_作业
//
// Created by YIem on 15/12/15.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//

import "Root1ViewController.h"

import "Root2ViewController.h"

@interface Root1ViewController ()

@end

@implementation Root1ViewController

  • (void)viewDidLoad {

    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor grayColor];
    // 标题
    UISegmentedControl *seg = [[UISegmentedControl alloc]initWithItems:@[@"第2.1页", @"第2.2页"]];
    seg.frame = CGRectMake(100, 100, 100, 30);
    seg.selectedSegmentIndex = 0;
    self.navigationItem.titleView = seg;
    [seg release];
    self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
    
    self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"1"] style:UIBarButtonItemStylePlain target:self action:@selector(seg)] autorelease];
    

    }

  • (void)seg
    {

    Root2ViewController *rootVC = [[Root2ViewController alloc]init];
    [self.navigationController pushViewController:rootVC animated:YES];
    [rootVC release];

    }

  • (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.

    }

/*

pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation

  • (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.

    }

*/

@end



//
// Root2ViewController.h
// UI7_作业
//
// Created by YIem on 15/12/15.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//

import <UIKit/UIKit.h>

@interface Root2ViewController : UIViewController

@end


//
// Root2ViewController.m
// UI7_作业
//
// Created by YIem on 15/12/15.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//

import "Root2ViewController.h"

@interface Root2ViewController ()

@end

@implementation Root2ViewController

  • (void)viewDidLoad {

    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor blueColor];
    
     self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
    
    
    UIBarButtonItem *item1 = [[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(leftAction)] autorelease];
    UIBarButtonItem *item2 = [[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(leftAction)] autorelease];
    self.navigationItem.rightBarButtonItems = @[item1, item2];
    
    

    }

  • (void)leftAction
    {

    }

  • (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.

    }

/*

pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation

  • (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.

    }

*/

@end