码迷,mamicode.com
首页 > 移动开发 > 详细

手机QQ底部分栏效果【标签栏】

时间:2014-11-02 09:30:00      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:des   io   color   ar   for   on   2014   cti   ad   

AppDelegate.m

//
//  AppDelegate.m
//  Task5
//
//  Created by lyb on 14-9-27.
//  Copyright (c) 2014年 imac. All rights reserved.
//

#import "AppDelegate.h"
#import "FirstViewController.h"
#import "SecondViewController.h"

@implementation AppDelegate

- (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];
    
    FirstViewController *firstCtrl = [[FirstViewController alloc] init];
    SecondViewController *secondCtrl =[[SecondViewController alloc] init];
    
    UINavigationController *navCtrl1 = [[UINavigationController alloc] initWithRootViewController:firstCtrl];
    UINavigationController *navCtrl2 = [[UINavigationController alloc] initWithRootViewController:secondCtrl];
    
    UITabBarController *tabbarCtrl = [[UITabBarController alloc] init];
    tabbarCtrl.viewControllers = @[navCtrl1, navCtrl2];
    
    self.window.rootViewController = tabbarCtrl;
    
    return YES;
}


@end

FirstViewController.m

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.title = @"左";
    
    self.view.backgroundColor = [UIColor redColor];
}

SecondViewController.m

#import "SecondViewController.h"
#import "ThirdViewController.h"

@interface SecondViewController ()

@end

@implementation SecondViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.title = @"右";
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor greenColor];
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeContactAdd];
    button.frame = CGRectMake(90, 90, 90, 50);
    [button addTarget:self action:@selector(buttonAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
}

- (void)buttonAction
{
    ThirdViewController *thirdCtrl = [[ThirdViewController alloc] init];
    
    [self.navigationController pushViewController:thirdCtrl animated:YES];
}

ThirdViewController.m

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        //隐藏标签栏工具栏
        self.hidesBottomBarWhenPushed = YES;
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.view.backgroundColor = [UIColor orangeColor];
    self.title = @"三";
    
}


手机QQ底部分栏效果【标签栏】

标签:des   io   color   ar   for   on   2014   cti   ad   

原文地址:http://blog.csdn.net/pengyuan_d/article/details/40682603

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!