forked from ChenYilong/CYLTabBarController
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppDelegate.m
73 lines (65 loc) · 2.64 KB
/
AppDelegate.m
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
//
// AppDelegate.m
// CYLTabBarController
//
// v1.21.x Created by 微博@iOS程序犭袁 ( http://weibo.com/luohanchenyilong/ ) on 10/20/15.
// Copyright © 2018 https://github.com/ChenYilong . All rights reserved.
//
#import "AppDelegate.h"
#import "CYLPlusButtonSubclass.h"
#import "CYLMainRootViewController.h"
@interface AppDelegate ()
@property (nonatomic, strong) NSMutableData *data;
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[UIApplication sharedApplication].statusBarHidden = NO;
// 设置主窗口,并设置根控制器
self.window = [[UIWindow alloc] init];
self.window.frame = [UIScreen mainScreen].bounds;
[self.window makeKeyAndVisible];
CYLMainRootViewController *rootViewController = [[CYLMainRootViewController alloc] init];
[self.window setRootViewController:rootViewController];
[self setUpNavigationBarAppearance];
return YES;
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmethod-signatures"
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
//设置强制旋转屏幕
if (self.cyl_isForceLandscape) {
//只支持横屏
return UIInterfaceOrientationMaskLandscape;
} else {
//只支持竖屏
return UIInterfaceOrientationMaskPortrait;
}
}
#pragma clang diagnostic pop
/**
* 设置navigationBar样式
*/
- (void)setUpNavigationBarAppearance {
UINavigationBar *navigationBarAppearance = [UINavigationBar appearance];
UIColor *backgroundColor = [UIColor cyl_systemBackgroundColor];
NSDictionary *textAttributes = nil;
UIColor *labelColor = [UIColor cyl_labelColor];
if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_6_1) {
textAttributes = @{
NSFontAttributeName : [UIFont boldSystemFontOfSize:18],
NSForegroundColorAttributeName : labelColor,
};
} else {
#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_7_0
textAttributes = @{
UITextAttributeFont : [UIFont boldSystemFontOfSize:18],
UITextAttributeTextColor : labelColor,
UITextAttributeTextShadowColor : [UIColor clearColor],
UITextAttributeTextShadowOffset : [NSValue valueWithUIOffset:UIOffsetZero],
};
#endif
}
[navigationBarAppearance setBarTintColor:backgroundColor];
[navigationBarAppearance setTitleTextAttributes:textAttributes];
}
@end