首页 > 代码库 > 导航控制器

导航控制器

//

//  FirstViewController.m

//  egg break

//

//  Created by apple on 14-7-16.

//  Copyright (c) 2014年 apple. All rights reserved.

//

 

#import "FirstViewController.h"

#import "SecondViewController.h"

@interface FirstViewController ()

{  //建立全局对象

    UIImageView *Bg1;

    UIImageView *Bg2;

    

}

 

 

@end

 

@implementation FirstViewController

 

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

{

    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

    if (self) {

        // Custom initialization

    }

    return self;

}

 

//创建背景

-(void)BgView

{

    Bg1=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];

    Bg1.image=[UIImage imageNamed:@"bg_01"];

    [self.view addSubview:Bg1];

    

    

    Bg2=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];

    Bg2.image=[UIImage imageNamed:@"bg_01_01"];

    [self.view addSubview:Bg2];

}

 

 

//建立侯爷

- (void)viewDidLoad

{

    [super viewDidLoad];

    [self BgView];

    UIButton *Btn=[UIButton buttonWithType:UIButtonTypeCustom];

    [Btn setImage:[UIImage imageNamed:@"H42_practice_nu"] forState:UIControlStateNormal];

    [Btn addTarget:self action:@selector(Click:) forControlEvents:UIControlEventTouchUpInside];

 

    Btn.frame=CGRectMake(0, 100, 50, 50);

    [self.view addSubview:Btn];

    

    UIButton *Btn1=[UIButton buttonWithType:UIButtonTypeCustom];

    [Btn1 setImage:[UIImage imageNamed:@"H63_practice_me"] forState:UIControlStateNormal    ];

    [Btn1 addTarget:self action:@selector(Click1:) forControlEvents:UIControlEventTouchUpInside];

    Btn1.frame=CGRectMake(100, 100, 50, 50);

    [self.view addSubview:Btn1];

    self.navigationController.navigationBarHidden=YES;

    

    

    

    // Do any additional setup after loading the view.

}

 

 

 

//建立按键

-(void)Click:(UIButton *)sender

{

    SecondViewController *Sec=[[SecondViewController alloc]init];

    Sec.title=@"1";

    Sec.Name=@"1";

    [self.navigationController pushViewController:Sec animated:YES];

}

 

-(void)Click1:(UIButton *)sender

{

    SecondViewController *Sec=[[SecondViewController alloc]init];

    Sec.title=@"2";

    Sec.Name=@"2";

    [self.navigationController pushViewController:Sec animated:YES];

 

}

 

- (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