forked from QMUI/QMUIDemo_iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppDelegate.m
More file actions
115 lines (92 loc) · 5.24 KB
/
AppDelegate.m
File metadata and controls
115 lines (92 loc) · 5.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
//
// 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