AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
UITabBarController *tabBarController = [[UITabBarController alloc] init];
FirstViewController *firstViewController = [[FirstViewController alloc] init];
firstViewController.title = @"首頁";
UIImage *image = [UIImage imageNamed:@"4-selected@2x.png"];
image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
UIImage *selectImage = [UIImage imageNamed:@"4-nomal@2x.png"];
selectImage = [selectImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
firstViewController.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"首頁" image:image selectedImage:selectImage];
UINavigationController *firseNavigaton = [[UINavigationController alloc] initWithRootViewController:firstViewController];
SecondViewController *secondViewController = [[SecondViewController alloc] init];
secondViewController.title = @"我的";
tabBarController.viewControllers = @[firseNavigaton,secondViewController];
self.window.rootViewController = tabBarController;
//tabBar屬性
tabBarController.tabBar.tintColor = [UIColor blackColor];
//tabBarController.tabBar.barTintColor = [UIColor greenColor];
//不透明
tabBarController.tabBar.translucent = NO;
return YES;
}
UITabBarController 就是像微信下面的(我的、發現、通訊錄、首頁)這類的東西,基本上的App都有這個,大家要熟練應用哦