溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

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

發布時間:2020-07-19 13:54:21 來源:網絡 閱讀:1058 作者:Im劉亞芳 欄目:開發技術

//

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


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女