// // AppDelegate.m // qmuidemo // // Created by ZhoonChen on 15/4/13. // Copyright (c) 2015年 QMUI Team. All rights reserved. // #import "AppDelegate.h" #import "QDUIHelper.h" #import "QDCommonUI.h" #import "QDTabBarViewController.h" #import "QDNavigationController.h" #import "QDUIKitViewController.h" #import "QDComponentsViewController.h" #import "QDLabViewController.h" #import "QMUIConfigurationTemplate.h" #import "QMUIConfigurationTemplateGrapefruit.h" #import "QMUIConfigurationTemplateGrass.h" #import "QMUIConfigurationTemplatePinkRose.h" @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // 应用 QMUI Demo 皮肤 NSString *themeClassName = [[NSUserDefaults standardUserDefaults] stringForKey:QDSelectedThemeClassName] ?: NSStringFromClass([QMUIConfigurationTemplate class]); [QDThemeManager sharedInstance].currentTheme = [[NSClassFromString(themeClassName) alloc] init]; // QD自定义的全局样式渲染 [QDCommonUI renderGlobalAppearances]; // 预加载 QQ 表情,避免第一次使用时卡顿(可选) dispatch_async(dispatch_get_global_queue(0, 0), ^{ [QMUIQQEmotionManager emotionsForQQ]; }); // 界面 self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; [self createTabBarController]; // 启动动画 [self startLaunchingAnimation]; return YES; } - (void)createTabBarController { QDTabBarViewController *tabBarViewController = [[QDTabBarViewController alloc] init]; // QMUIKit QDUIKitViewController *uikitViewController = [[QDUIKitViewController alloc] init]; uikitViewController.hidesBottomBarWhenPushed = NO; QDNavigationController *uikitNavController = [[QDNavigationController alloc] initWithRootViewController:uikitViewController]; uikitNavController.tabBarItem = [QDUIHelper tabBarItemWithTitle:@"QMUIKit" image:[UIImageMake(@"icon_tabbar_uikit") imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:UIImageMake(@"icon_tabbar_uikit_selected") tag:0]; // UIComponents QDComponentsViewController *componentViewController = [[QDComponentsViewController alloc] init]; componentViewController.hidesBottomBarWhenPushed = NO; QDNavigationController *componentNavController = [[QDNavigationController alloc] initWithRootViewController:componentViewController]; componentNavController.tabBarItem = [QDUIHelper tabBarItemWithTitle:@"Components" image:[UIImageMake(@"icon_tabbar_component") imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:UIImageMake(@"icon_tabbar_component_selected") tag:1]; // Lab QDLabViewController *labViewController = [[QDLabViewController alloc] init]; labViewController.hidesBottomBarWhenPushed = NO; QDNavigationController *labNavController = [[QDNavigationController alloc] initWithRootViewController:labViewController]; labNavController.tabBarItem = [QDUIHelper tabBarItemWithTitle:@"Lab" image:[UIImageMake(@"icon_tabbar_lab") imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:UIImageMake(@"icon_tabbar_lab_selected") tag:2]; // window root controller tabBarViewController.viewControllers = @[uikitNavController, componentNavController, labNavController]; self.window.rootViewController = tabBarViewController; [self.window makeKeyAndVisible]; } - (void)startLaunchingAnimation { UIWindow *window = [[[UIApplication sharedApplication] delegate] window]; UIView *launchScreenView = [[NSBundle mainBundle] loadNibNamed:@"LaunchScreen" owner:self options:nil].firstObject; launchScreenView.frame = window.bounds; [window addSubview:launchScreenView]; UIImageView *backgroundImageView = launchScreenView.subviews[0]; backgroundImageView.clipsToBounds = YES; UIImageView *logoImageView = launchScreenView.subviews[1]; UILabel *copyrightLabel = launchScreenView.subviews.lastObject; UIView *maskView = [[UIView alloc] initWithFrame:launchScreenView.bounds]; maskView.backgroundColor = UIColorWhite; [launchScreenView insertSubview:maskView belowSubview:backgroundImageView]; [launchScreenView layoutIfNeeded]; [launchScreenView.constraints enumerateObjectsUsingBlock:^(__kindof NSLayoutConstraint * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { if ([obj.identifier isEqualToString:@"bottomAlign"]) { obj.active = NO; [NSLayoutConstraint constraintWithItem:backgroundImageView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:launchScreenView attribute:NSLayoutAttributeTop multiplier:1 constant:NavigationContentTop].active = YES; *stop = YES; } }]; [UIView animateWithDuration:.15 delay:0.9 options:QMUIViewAnimationOptionsCurveOut animations:^{ [launchScreenView layoutIfNeeded]; logoImageView.alpha = 0.0; copyrightLabel.alpha = 0; } completion:nil]; [UIView animateWithDuration:1.2 delay:0.9 options:UIViewAnimationOptionCurveEaseOut animations:^{ maskView.alpha = 0; backgroundImageView.alpha = 0; } completion:^(BOOL finished) { [launchScreenView removeFromSuperview]; }]; } @end