SystemMacro.h
5.75 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
//
// SystemMacro.h
// CNLiveScioLive
//
// Created by CNLive-zxw on 2018/9/18.
// Copyright © 2018年 CNLive. All rights reserved.
//
#ifndef SystemMacro_h
#define SystemMacro_h
#ifndef AppKeyWindow
#define AppKeyWindow ((AppDelegate *)[UIApplication sharedApplication].delegate).window
#endif
//协议调取方法
#define CNMessageSend(instance,protocol,message) [(id<protocol>)(instance) message]
// 系统语言
#define SYSTEM_LANGUAGE [[[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"] objectAtIndex:0]
#define IS_CHINESE ([SYSTEM_LANGUAGE isEqualToString:@"zh-Hans-CN"]||[SYSTEM_LANGUAGE isEqualToString:@"zh-Hant-CN"]||[SYSTEM_LANGUAGE isEqualToString:@"zh-Hans"] ||[SYSTEM_LANGUAGE isEqualToString:@"zh-hans"])
#define Language_Local @"Language_Local"
#define CustomStr(key) [(AppDelegate *)[[UIApplication sharedApplication] delegate] showText:(key)]
#define lan_html (IS_CHINESE ? @"zh" : @"en")
//支持的语言包
#define HasSupportedLocalizedResource ([SYSTEM_LANGUAGE hasPrefix:@"zh"])
//国际化的宏
#define EQDLocalizedString(key, comment) \
(HasSupportedLocalizedResource?([[NSBundle mainBundle] localizedStringForKey:(key) value:@"" table:nil]):([[NSBundle bundleWithPath:BundlePath(@"en", @"lproj")] localizedStringForKey:key value:@"" table:nil]))
/**
系统及设备
*/
#define iOS7 [[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0
#define iOS8 [[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0
#define iOS9 [[[UIDevice currentDevice] systemVersion] floatValue] >= 9.0
#define iOS6 [[[UIDevice currentDevice] systemVersion] floatValue] >= 6.0 && [[[UIDevice currentDevice] systemVersion] floatValue] < 7.0
#define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)
#define iTouch ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(320, 480), [[UIScreen mainScreen] currentMode].size) : NO)
#define iPhone6Plus ((ScreenWidth==414)?YES:NO)
#define iPhone6 ((ScreenWidth==375)?YES:NO)
#define iPhone320 ((ScreenWidth==320)?YES:NO)
#define iPhone4 ((ScreenHeight==480)?YES:NO)
//适配iphoex
//#define iPhoneX ((MainScreenHeight == 812.0f) ? YES : NO)
// 是否是iPhone X系列
#define iPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ?\
(\
CGSizeEqualToSize(CGSizeMake(375, 812),[UIScreen mainScreen].bounds.size)\
||\
CGSizeEqualToSize(CGSizeMake(812, 375),[UIScreen mainScreen].bounds.size)\
||\
CGSizeEqualToSize(CGSizeMake(414, 896),[UIScreen mainScreen].bounds.size)\
||\
CGSizeEqualToSize(CGSizeMake(896, 414),[UIScreen mainScreen].bounds.size))\
:\
NO)
//区分真机还是模拟器
#if TARGET_IPHONE_SIMULATOR//模拟器
#define SIMULATOR 1
#elif TARGET_OS_IPHONE//真机
#define SIMULATOR 0
#endif
/**
* 适配
*/
#define MainScale MainScreenWidth/375.f
#define MainHScale MainScreenHeight/667.f
#define NavBarHeight ((iPhoneX==YES) ? 88.0f: 64.0f)
#define StatusBarHeight ((iPhoneX==YES) ? 44.0f: 20.0f)
#define TabBarHeight ((iPhoneX==YES) ? 83.0f: 49.0f)
#define MainScreenWidth [[UIScreen mainScreen] bounds].size.width
#define MainScreenHeight [[UIScreen mainScreen] bounds].size.height
#define NavBarContentHeight 44.0f
/**
* 系统方法
*/
#define WS(weakSelf) __weak __typeof(&*self)weakSelf = self;
#define Notification_Center [NSNotificationCenter defaultCenter]
#define Application_Delegate ((AppDelegate *)[[UIApplication sharedApplication] delegate])
#define KeyWindowRootController [[[UIApplication sharedApplication] keyWindow] rootViewController]
#define NS_Bundle [NSBundle mainBundle]
#define User_Defaults [NSUserDefaults standardUserDefaults]
#define LoginSuccessful @"LoginSuccessful"
#define ExitSuccessful @"ExitSuccessful"
#define GetCodeSuccessful @"GetCodeSuccessful"
#define ISGRAYMODE @"isGrayMode"
#define HOMETITLECOLOR @"homeTitleColor"
#define HOMETITLECOLORSTR [[NSUserDefaults standardUserDefaults] valueForKey:HOMETITLECOLOR]
//图片
#define Image(image) [UIImage imageNamed:image]
//字体
#define Font(size) [UIFont systemFontOfSize:size]
#define BFont(size) [UIFont boldSystemFontOfSize:size]
//颜色
#define HEXCOLOR(c) [UIColor colorWithRed:((c>>16)&0xFF)/255.0 green:((c>>8)&0xFF)/255.0 blue:(c&0xFF)/255.0 alpha:1.0]
#define HEXCOLORA(c,a) [UIColor colorWithRed:((c>>16)&0xFF)/255.0 green:((c>>8)&0xFF)/255.0 blue:(c&0xFF)/255.0 alpha:a]
/**
* 16进制转化颜色
*/
#define UIColorFromRGB(rgbValue,A) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:A]
/**
* 定义Rect
*/
#define rect(x,y,w,h) CGRectMake(x,y,w,h)
/**
* 定义point
*/
#define point(x,y) CGPointMake(x,y)
/**
* 定义size
*/
#define size(w,h) CGSizeMake(w,h)
/**
* 获取最大X,Y
*/
#define maxX(rect) CGRectGetMaxX(rect)
#define maxY(rect) CGRectGetMaxY(rect)
/**
* 获取最小X,Y
*/
#define minX(rect) CGRectGetMinX(rect)
#define minY(rect) CGRectGetMinY(rect)
/**
* 获取矩形宽,高
*/
#define rectW(rect) CGRectGetWidth(rect)
#define rectH(rect) CGRectGetHeight(rect)
#define cellItemWidth (MainScreenWidth - 24)
#define cellItemHeight (cellItemWidth*5/8)
#define leftImageCellWidth (MainScreenWidth*3/8)
#define threeImageCellWidth ((cellItemWidth - 16)/3)
#endif /* SystemMacro_h */