#warning 面向字典开发很麻烦 我们最好把字典转为模型
#import "AppDelegate.h"
#import "QHTabbarViewController.h"
#import "QHNewfeatureViewController.h"
#import "QHOAuthViewController.h"
#import "QHAccount.h"
#import "QHAccountTool.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
//1.创建窗口
self.window = [[UIWindow alloc]init];
self.window.frame = [UIScreen mainScreen].bounds;
//2.显示窗口
[self.window makeKeyAndVisible];
//3.设置根视图控制器
QHAccount *account = [QHAccountTool account];
if (account) {//之前已经登录成功
[UIWindow switchRootViewController];
}else {
self.window.rootViewController = [[QHOAuthViewController alloc]init];
}
// NSLog(@"%@",NSHomeDirectory());
return YES;
}
/**
传控制器
*/
- (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:.
}
/**
* //3.设置子控制器
UIViewController *vc1 = [[UIViewController alloc]init];
vc1.tabBarItem.title = @"首页";
vc1.tabBarItem.image = [UIImage imageNamed:@"tabbar_home"];
//UIImage *homeSelectedImage = [UIImage imageNamed:@"tabbar_home_selected"];//自定义渲染成蓝色
//声明这张图片 以后按照原始的样子显示出来 不要自动渲染成其他颜色(比如蓝色)
// homeSelectedImage = [homeSelectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];//这个是新技术ios7
// vc1.tabBarItem.selectedImage = homeSelectedImage;
vc1.tabBarItem.selectedImage = [[UIImage imageNamed:@"tabbar_home_selected" ] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
vc1.view.backgroundColor = QHRandomColor;
//设置文字颜色
NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
textAttrs[NSForegroundColorAttributeName] =[UIColor colorWithRed:0.49f green:0.49f blue:0.49f alpha:1.00f];
[vc1.tabBarItem setTitleTextAttributes:textAttrs forState:UIControlStateNormal];
NSMutableDictionary *selectedTextAttrs =[NSMutableDictionary dictionary];
selectedTextAttrs[NSForegroundColorAttributeName] = [UIColor orangeColor];
[vc1.tabBarItem setTitleTextAttributes:selectedTextAttrs forState:UIControlStateSelected];
UIViewController *vc2 = [[UIViewController alloc]init];
vc2.tabBarItem.title = @"消息";
vc2.view.backgroundColor = QHRandomColor;
vc2.tabBarItem.image = [UIImage imageNamed:@"tabbar_message_center"];
vc2.tabBarItem.selectedImage = [[UIImage imageNamed:@"tabbar_message_center_selected"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
[vc2.tabBarItem setTitleTextAttributes:textAttrs forState:UIControlStateNormal];
[vc2.tabBarItem setTitleTextAttributes:selectedTextAttrs forState:UIControlStateSelected];
UIViewController *vc3 = [[UIViewController alloc]init];
vc3.view.backgroundColor = QHRandomColor;
vc3.tabBarItem.title = @"发现";
vc3.tabBarItem.image = [UIImage imageNamed:@"tabbar_discover"];
vc3.tabBarItem.selectedImage = [[UIImage imageNamed:@"tabbar_discover_selected"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
[vc3.tabBarItem setTitleTextAttributes:textAttrs forState:UIControlStateNormal];
[vc3.tabBarItem setTitleTextAttributes:selectedTextAttrs forState:UIControlStateSelected];
UIViewController *vc4 = [[UIViewController alloc]init];
vc4.view.backgroundColor = QHRandomColor;
vc4.tabBarItem.title = @"我";
vc4.tabBarItem.image = [UIImage imageNamed:@"tabbar_profile"];
vc4.tabBarItem.selectedImage = [[UIImage imageNamed:@"tabbar_profile_selected"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
[vc4.tabBarItem setTitleTextAttributes:textAttrs forState:UIControlStateNormal];
[vc4.tabBarItem setTitleTextAttributes:selectedTextAttrs forState:UIControlStateSelected];
*/
@end