開頭不要忘了刪Main
#import "AppDelegate.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
/*——————————————————————————————————————————————————————————————————————————————-*/
UIViewController *vc1 = [[UIViewController alloc]init];
vc1.view.backgroundColor = [UIColor redColor];
vc1.title = @"第一頁";
UIViewController *vc2 = [[UIViewController alloc]init];
vc2.view.backgroundColor = [UIColor yellowColor];
vc2.title = @"第二頁";
UIViewController *vc3 = [[UIViewController alloc]init];
vc3.view.backgroundColor = [UIColor blueColor];
vc3.title = @"第三頁";
/**
UITabBarSystemItemMore,
UITabBarSystemItemFavorites,
UITabBarSystemItemFeatured,
UITabBarSystemItemTopRated,
UITabBarSystemItemRecents,
UITabBarSystemItemContacts,
UITabBarSystemItemHistory,
UITabBarSystemItemBookmarks,
UITabBarSystemItemSearch,
UITabBarSystemItemDownloads,
UITabBarSystemItemMostRecent,
UITabBarSystemItemMostViewed,
*/
//系統(tǒng)樣式創(chuàng)建
UITabBarItem *item1 = [[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemBookmarks tag:101];
//通過 標題 圖片 選中圖片 --> 創(chuàng)建標簽項
UITabBarItem *item2 = [[UITabBarItem alloc]initWithTitle:@"HOME" image:[UIImage imageNamed:@"home"] selectedImage:[UIImage imageNamed:@"home_on"]];
//
UITabBarItem *item3 = [[UITabBarItem alloc]initWithTitle:@"payticket" image:[UIImage imageNamed:@"payticket"] tag:103];
vc1.tabBarItem = item1;
vc2.tabBarItem = item2;
vc3.tabBarItem = item3;
/*———————————————————導(dǎo)航控制器———————————————————————————————————————————————————————————-*/
UINavigationController *nav1 = [[UINavigationController alloc]initWithRootViewController:vc1];
UINavigationController *nav2 = [[UINavigationController alloc]initWithRootViewController:vc2];
UINavigationController *nav3 = [[UINavigationController alloc]initWithRootViewController:vc3];
/**
應(yīng)用程序的基本層級關(guān)系:
UIScreen -> UIWindow -> ROOTVC = TabBarController
↓
ViewControllers = @[UINavigationController >=1]
↓
rootViewController = UIViewController
↓
(各種控件)subviews <== view
*/
//創(chuàng)建 標簽控制器
UITabBarController *tbc = [[UITabBarController alloc]init];
//設(shè)置 標簽控制器管理的子控制器數(shù)組
tbc.viewControllers = @[nav1,nav2,nav3];
//將標簽控制器管理的子控制器數(shù)組
self.window.rootViewController = tbc;
return YES;
}
@end
屏幕快照 2016-03-08 上午10.15.10.png