自定义的累似UINavigationController
查看次数:2857
下载次数:21
上传时间:2015-06-30
大小:
//
// ViewController.m
// SelfNavi
//
// Created by Calvin.Nie on 15/6/30.
// Copyright (c) 2015年 Calvin.Nie. All rights reserved.
//
#import "ViewController.h"
#import "BarItem.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self loadAllView];
}
-(void)loadAllView
{
_selectView=[[UIView alloc]initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width/4.*3, 0, [UIScreen mainScreen].bounds.size.width/4., 44)];
_selectView.backgroundColor=[UIColor whiteColor];
_selectView.alpha=0.7;
_navi=[[NaviToolbar alloc]initWithFrame:CGRectMake(0,[UIScreen mainScreen].bounds.size.height-44, [UIScreen mainScreen].bounds.size.width, 44)];
_navi.backgroundColor=[UIColor blackColor];
[self.view addSubview:_navi];
_frist=[[FristViewController alloc]init];
[_frist view];
[self.view insertSubview:_frist.view belowSubview:_navi];
_second=[[SecondViewController alloc]init];
[self.view insertSubview:_second.view belowSubview:_navi];
_three=[[ThreeViewController alloc]init];
[self.view insertSubview:_three.view belowSubview:_navi];
_third=[[ThirdViewController alloc]init];
[self.view insertSubview:_third.view belowSubview:_navi];
NSMutableArray *m_allBar=[[NSMutableArray alloc]init];
BarItem *b1=[[BarItem alloc]initWithImage:[UIImage imageNamed:@"1"] style:UIBarButtonItemStylePlain target:self action:YES Viewcontroller:_frist];
b1.delegate=self;
BarItem *b2=[[BarItem alloc]initWithImage:[UIImage imageNamed:@"2"] style:
UIBarButtonItemStylePlain target:self action:YES Viewcontroller:_second];
b2.delegate=self;
BarItem *b3=[[BarItem alloc]initWithImage:[UIImage imageNamed:@"3"] style:UIBarButtonItemStylePlain target:self action:YES Viewcontroller:_three];
b3.delegate=self;
BarItem *b4=[[BarItem alloc]initWithImage:[UIImage imageNamed:@"4"] style:UIBarButtonItemStylePlain target:self action:YES Viewcontroller:_third];
b4.delegate=self;
[m_allBar addObject:b1];
[m_allBar addObject:b2];
[m_allBar addObject:b3];
[m_allBar addObject:b4];
[_navi setItems:m_allBar];
[_navi addSubview:_selectView];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)switchView:(UIButton *)sender
{
NSLog(@"----------%d",sender.tag);
_selectView.frame=CGRectMake([UIScreen mainScreen].bounds.size.width/4.*(sender.tag-1), 0, [UIScreen mainScreen].bounds.size.width/4., 44);
switch (sender.tag) {
case 1:
{
[self.view insertSubview:_frist.view belowSubview:_navi];
}
break;
case 2:
{
[self.view insertSubview:_second.view belowSubview:_navi];
}
break;
case 3:
{
[self.view insertSubview:_three.view belowSubview:_navi];
}
break;
case 4:
{
[self.view insertSubview:_third.view belowSubview:_navi];
}
break;
default:
break;
}
}
@end
收藏