UITabBarController的使用----底部导航

发布时间:2020-07-19 13:54:21 作者:Im刘亚芳
来源:网络 阅读:1034

//

//  AppDelegate.m

//  UITabBarController9-11

//

//  Created by liuyafang on 14-9-11.

//  Copyright (c) 2014 lanou3g.com 蓝鸥科技. All rights reserved.

//


#import "AppDelegate.h"

#import "FirstViewController.h"

#import "SecondViewController.h"

#import "ThirdViewController.h"

#import "FourthViewController.h"

#import "FifthViewController.h"

#import "SixthViewController.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];

    //UITabBarController的使用

    UITabBarController *tabVC = [[UITabBarController alloc] init];

    self.window.rootViewController = tabVC;  //UITabBarController设置为根试图控制器


 

    

    FirstViewController *firetVC = [[FirstViewController alloc] init];

    firetVC.title = @"";

    firetVC.tabBarItem.p_w_picpath = [UIImage p_w_picpathNamed:@"6.png"];

    //1.(初始化)直接调用系统图标 tag

    firetVC.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemSearch tag:100];

    

  

    

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

    secondVC.title = @"";

    secondVC.tabBarItem.p_w_picpath = [UIImage p_w_picpathNamed:@"5.png"];

    //2.(初始化)标题不变  图片点击后会改变

    secondVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"hehe" p_w_picpath:[UIImage p_w_picpathNamed:@"6.png"] selectedImage:[UIImage p_w_picpathNamed:@"5.png"]];

    

    

    

    

    ThirdViewController *thirdVC = [[ThirdViewController alloc] init];

    thirdVC.title = @"";

    thirdVC.tabBarItem.p_w_picpath = [UIImage p_w_picpathNamed:@"4.png"];

    //3.(初始化)标题可变,图标可变,还有tag

    thirdVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"嘻嘻" p_w_picpath:[UIImage p_w_picpathNamed:@"4.png"] tag:200];

    

    

    FourthViewController *fourthVC = [[FourthViewController alloc] init];

    fourthVC.title = @"";

    fourthVC.tabBarItem.p_w_picpath = [UIImage p_w_picpathNamed:@"3.png"];

//    //保持图片原有形态加入到tabBar

//    UIImage *p_w_picpath = [UIImage p_w_picpathNamed:@"aa.png"];

//    //对图片进行处理

//    p_w_picpath = [p_w_picpath p_w_picpathWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

//    fourthVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"嘻嘻" p_w_picpath:[UIImage p_w_picpathNamed:@"aa.png"] tag:300];

    

    

    

    

    FifthViewController *fifthVC = [[FifthViewController alloc] init];

    fifthVC.title = @"";

    fifthVC.tabBarItem.p_w_picpath = [UIImage p_w_picpathNamed:@"1.png"];

//    SixthViewController *sixthVC = [[SixthViewController alloc] init];

    

    

    

    

    //UINavigationControllertabBar结合起来

    //1.把第一个VC设置为navVC的根试图控制器

    //2.banavVC视图控制器存放到数组中

    UINavigationController *navVC = [[UINavigationController alloc] initWithRootViewController:firetVC];

    

    

    

    //创建一个试图控制器的数组

    NSArray *array = [NSArray arrayWithObjects:navVC, secondVC, thirdVC, fourthVC, fifthVC,  nil];

    //把数组放到tabBarController

    tabVC.viewControllers = array;

    //调整tabBer的颜色

    tabVC.tabBar.backgroundColor = [UIColor cyanColor];

    //字体选中后的颜色

    tabVC.tabBar.tintColor = [UIColor redColor];

    //调整bar模糊效果

    tabVC.tabBar.translucent = YES;

    

    

    [tabVC release];

    

    [_window release];

    return YES;

}


- (void)dealloc

{

    [_window release];

    [super dealloc];

}


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


推荐阅读:
  1. UITabBarController的基本原理及使用(二)
  2. UITabBarController的基本原理及使用(一)

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

import copyright roller

上一篇:浅析:LoRa这项应用于低功率长距离场景的物联网传输技术的优劣

下一篇:调用app stroe

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》