CNLiveDefinesHeader.h
5.91 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
155
156
157
158
159
160
//
// CNLiveDefinesHeader.h
// CNLiveCommonCategory
//
// Created by 张旭 on 2018/9/26.
// Copyright © 2018年 cnlive. All rights reserved.
//
#ifndef CNLiveDefinesHeader_h
#define CNLiveDefinesHeader_h
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "ColorHeaders.h"
//#import "CNLiveARCCompile.h" 暂时用不到
////////////////////////////////////////////////////////
//////////// Color
////////////////////////////////////////////////////////
// 默认的字体颜色
#define kMainTextColor kBlackColor
#define kAppBakgroundColor kWhiteColor
// 主色调
// 导航按钮
#define kNavBarThemeColor RGB(128, 64, 122)
#define kDetailTextColor RGB(145, 145, 145)
// 默认TableViewCell高度
#define kDefaultCellHeight 69
// 默认界面之间的间距
#define kDefaultMargin 5
////////////////////////////////////////////////////////
//////////// Font
////////////////////////////////////////////////////////
// CommonLibrary中常用的字体
#define kCommonLargeTextFont [UIFont systemFontOfSize:16]
#define kCommonMiddleTextFont [UIFont systemFontOfSize:14]
#define kCommonSmallTextFont [UIFont systemFontOfSize:12]
////////////////////////////////////////////////////////
//////////// SCreen
////////////////////////////////////////////////////////
#define KScreenWidth ([UIScreen mainScreen].bounds.size.width > [UIScreen mainScreen].bounds.size.height ? [UIScreen mainScreen].bounds.size.height : [UIScreen mainScreen].bounds.size.width)
#define KScreenHeight ([UIScreen mainScreen].bounds.size.width > [UIScreen mainScreen].bounds.size.height ? [UIScreen mainScreen].bounds.size.width : [UIScreen mainScreen].bounds.size.height)
//判断iPHoneXr
#define Device_Is_iPhoneXS_XR ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(828, 1792), [[UIScreen mainScreen] currentMode].size) : NO)
//判断iPHoneX、iPHoneXs
#define Device_Is_iPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)
#define Device_Is_iPhoneXS ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)
//判断iPhoneXs Max
#define Device_Is_iPhoneXS_MAX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2688), [[UIScreen mainScreen] currentMode].size) : NO)
#define IS_IPhoneX_All (CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(375, 812)) ||CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(812, 375)) ||CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(414, 896)) ||CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(896, 414)))
#define kStatusHeight (int)[UIApplication sharedApplication].statusBarFrame.size.height //x44 非x20
#define kNavigationBarHeight ((int)[UIApplication sharedApplication].statusBarFrame.size.height+44) //x88 非x64
#define kVerticalNaviBarHeight ((IS_IPhoneX_All > 0) ? 88 : 44)
#define kVerticalTabBarTotalHeight ((IS_IPhoneX_All > 0) ? 83 : 49)
#define kVerticalBottomSafeHeight ((IS_IPhoneX_All > 0) ? 34 : 0)
#define kVerticalStatusHeight ((IS_IPhoneX_All > 0) ? 44 : 20)
#define kVerticalTopHeight ((IS_IPhoneX_All > 0) ? 24 : 0)
#define kHorizontalTopNaviBarHeight 32
#define kHorizontalBottomHeight ((IS_IPhoneX_All > 0) ? 21 : 0)
#define kHorizontalLeftHeight ((IS_IPhoneX_All > 0) ? 44 : 0)
#define kHorizontalRightHeight ((IS_IPhoneX_All > 0) ? 44 : 0)
#define kHorizontalTopHeight ((IS_IPhoneX_All > 0) ? 24 : 0)
////////////////////////////////////////////////////////
//////////// WeakSelf&StrongSelf
////////////////////////////////////////////////////////
/**
* weakSelf
*/
#ifndef weakself
#define weakself __weak typeof(self)weakSelf = self;
#endif
/**
* strongSelf
*/
#ifndef strongself
#define strongself __strong typeof(weakSelf)self = weakSelf;
#endif
////////////////////////////////////////////////////////
//////////// 输出测试
////////////////////////////////////////////////////////
#ifdef DEBUG
#define NSLog(s, ... ) NSLog( @"[%@ in line %d] ===============>%@", [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] )
#else
#define NSLog(s, ... )
#endif
#ifdef DEBUG
#ifndef DebugLog
#define DebugLog(fmt, ...) NSLog((@"[%s Line %d] \n" fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#endif
#else
#ifndef DebugLog
#define DebugLog(fmt, ...)
#endif
#endif
////////////////////////////////////////////////////////
//////////// 动态跟随系统设置的字体大小改变字体和行高
////////////////////////////////////////////////////////
#define RATIO [CNSetUserDefaultTool getScaleCoefficient]
//这个字体宏可以统一成UIFontMake()
//字体大小
#define Text_FONT(F) [UIFont systemFontOfSize:F]
#define contentLabelFontSize 16
////////////////////////////////////////////////////////
//////////// AppDelegate
////////////////////////////////////////////////////////
#ifndef AppKeyWindow
#define AppKeyWindow [IMAAppDelegate sharedAppDelegate].window
#endif
////////////////////////////////////////////////////////
//////////// NSNotificationCenter
////////////////////////////////////////////////////////
#define CNNotificationCenter [NSNotificationCenter defaultCenter]
#define SINGLETON_FOR_HEADER(className) \
\
+ (className *)shared##className;
#define SINGLETON_FOR_CLASS(className) \
\
+ (className *)shared##className { \
static className *shared##className = nil; \
static dispatch_once_t onceToken; \
dispatch_once(&onceToken, ^{ \
shared##className = [[self alloc] init]; \
}); \
return shared##className; \
}
#define AppVersion [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]
#endif /* CNLiveDefinesHeader_h */