logo头像
Snippet 博客主题

Const文件相关内容

  • 屏幕适配相关
  • 文件导入
  • 颜色字体相关
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
//
// Const.swift
//
// Created by 刘刘峰 on 2019/11/3.
// Copyright © 2019 刘刘峰. All rights reserved.
//

import Foundation
import UIKit
import SnapKit
import Kingfisher
import Toast
import SwiftMessages

@_exported import SwiftyJSON
@_exported import HandyJSON
@_exported import IQKeyboardManagerSwift
@_exported import SwifterSwift
@_exported import Moya


let kScreenBounds = UIScreen.main.bounds
let kScreenWidth = UIScreen.main.bounds.size.width
let kScreenHeigth = UIScreen.main.bounds.size.height
let DominantColor = UIColor.init(red: 242/255.0, green: 77/255.0, blue: 51/255.0, alpha: 1)
let FooterViewColor = UIColor.init(red: 240/255.0, green: 241/255.0, blue: 244/255.0, alpha: 1)

// iphone X
let isIphoneX = kScreenHeigth == 812 ? true : false
let isIphone11 = kScreenHeigth == 896 ? true : false
let isIphoneXAll = isIphoneX||isIphone11
let isPad = DeviceInfo.isIPad()

//let ZYIsiPhoneX: Bool = UIScreen.instancesRespond(to: #selector(getter: UIScreen.currentMode)) && UIScreen.main.currentMode!.size == CGSize(width: 1125, height: 2436)

// navigationBarHeight
let navigationBarHeight : CGFloat = isIphoneXAll ? 88 : 64
// tabBarHeight
let tabBarHeight : CGFloat = isIphoneXAll ? 49 + 34 : 49

let statusBarHeight: CGFloat = isIphoneXAll ? 44 : 20

//@available(iOS 13.0, *)
//let kkwindow = (UIApplication.shared.connectedScenes.first?.delegate as? UIWindowSceneDelegate)?.window as? UIWindow
let kkwindow = UIApplication.shared.windows.first

//MARK:通用闭包
public typealias LFCallBack = ()->()
public typealias LFIndexCallBack = (_ selectRow:Int)->()
public typealias LFStringCallBack = (_ String:String)->()
public typealias LFButtonCallBack = (_ sender:UIButton)->()
//public typealias LFDataCallBack = (_ dataCenter:PXSDataCenter)->()


enum AppConstants {

//MARK: - 是否是测试环境
static let NetDebug: Bool = true

//MARK: - 随机颜色
static let ColorDebug: Bool = false

//MARK: - 日志输出
static let LogDebug: Bool = true

//存储-用户信息-键
static let CurrentLoginUserInfo: String = ""

static let KeyChainService: String = ""

//存储-网络请求token-键
static let NetworkToken: String = "NetworkToken"

//MARK: - 协议(http/https)(含“//”后缀,不能为空)
enum AppURLProtocol {

//测试
static let DebugProtocol = "https://"

//生产
static let ProduceProtocol = "https://"
}

//MARK: - 地址(host) (不能为空)
enum AppURLHOST {

//测试
static let DebugHOST = "项目测试域名"

//生产
static let ProduceHOST = "项目生产域名"
}

//MARK: - 端口(port),(含“:”前缀,如果 URL_PORT 为空,则不含)
enum AppURLPort {

//测试
static let DebugPort = ""

//生产
static let ProducePort = ""
}

//MARK: - 接口地址
enum AppInterfaceAddress {

//登录
static let Login = "接口地址路由"

}


//MARK: - APP的key
enum AppKey {

static let UMeng = "三方Key"

//......

}

//MARK: - APP的密钥
enum AppSecret {

static let UMeng = "三方密钥"

//......

}

//MARK: - 错误类型
enum ErrorType {

static let ServerError = "服务器异常"

}

}

//MARK: - 日志输出
// <T>: 为泛型,外界传入什么就是什么
func DLog<T>(_ message: T, file: String = #file, method: String = #function, line: Int = #line) {

if AppConstants.LogDebug {

print("\(method)[\(line)]:\(message)")

}

}

//MARK: - frame 相关
/************************ 屏幕尺寸 ***************************/

public enum AppFrame {

static let ScreenBounds = UIScreen.main.bounds

// 屏幕宽度
static let ScreenWidth = ScreenBounds.size.width

// 屏幕高度
static let ScreenHeight = ScreenBounds.size.height

// iPhone4
static let iPhone4 = ScreenHeight < 568 ? true : false

// iPhone 5
static let iPhone5 = ScreenHeight == 568 ? true : false

// iPhone 6
static let iPhone6 = ScreenHeight == 667 ? true : false

// iphone 6P
static let iPhone6P = ScreenHeight == 736 ? true : false

// iphone X XS
static let iPhoneX = ScreenHeight == 812 ? true : false

// iphone XR XSMax
static let iPhoneXR = ScreenHeight == 896 ? true : false



// navigationBarHeight
static let kNavigationBarHeight : CGFloat = iPhoneX ? 88 : 64

// tabBarHeight
static let kTabBarHeight : CGFloat = iPhoneX ? 49 + 34 : 49

/** 如果是iPhoneX按照Plus 尺寸计算比例 */
static let Scale_Height = iPhoneX ? 736.0/667.0 : ScreenHeight / 667
static let Scale_Width = ScreenWidth / 375

}


func ADAPTX(x:CGFloat) -> CGFloat {

return AppFrame.Scale_Width * x

}

func ADAPTY(y:CGFloat) -> CGFloat {

return AppFrame.Scale_Height * y

}

// MARK: ============================================================================
// MARK: 设置颜色

//MARK: - AppColor 相关
public enum AppColor {

static let clear = UIColor.clear

//APP主题色
// static let themeColor = RGB0X(hexValue: 0x3eb2e5)
// static let themeColor = RGB0X(hexValue: 0x03a9f4)
static let themeColor = RGB0X(hexValue: 0xF78934)

//2196f3
//白色
static let white = RGB0X(hexValue: 0xFFFFFF)
//APP红色
static let red = RGB0X(hexValue: 0xff2323)
//APP蓝色
static let blue = RGB0X(hexValue: 0x488ff0)
//APP黑色
static let black = RGB0X(hexValue: 0x252525)
//APP深灰色
static let darkgGray = RGB0X(hexValue: 0x666666)
//APP灰色
static let gray = RGB0X(hexValue: 0x989796)
//APP轻灰色
static let lightGray = RGB0X(hexValue: 0xcccccc)
//APP背景色
static let vcBgColor = RGB0X(hexValue: 0xF7F7F7)

static let lineColor = RGB0X(hexValue: 0xF0EFED)

//热门标签
static let hotColor = RGB0X(hexValue: 0xFC868B)
//推荐标签
static let recomColor = RGB0X(hexValue: 0x6AD8B3)



}

/// RGBA的颜色设置
func RGB(_ r:CGFloat, g:CGFloat, b:CGFloat) -> UIColor {

return UIColor(red: r / 255.0, green: g / 255.0, blue: b / 255.0, alpha: 1.0)

}

func RGBA(_ r:CGFloat, g:CGFloat, b:CGFloat, a:CGFloat) -> UIColor {

return UIColor(red: r / 255.0, green: g / 255.0, blue: b / 255.0, alpha: a)

}

func HEXA(hexValue: Int, a: CGFloat) -> (UIColor) {

return UIColor(red: ((CGFloat)((hexValue & 0xFF0000) >> 16)) / 255.0,
green: ((CGFloat)((hexValue & 0xFF00) >> 8)) / 255.0,
blue: ((CGFloat)(hexValue & 0xFF)) / 255.0,
alpha: a)

}

func RGB0X(hexValue: Int) -> (UIColor) {

return HEXA(hexValue: hexValue, a: 1.0)

}

// MARK: ============================================================================
// MARK: 设置字体

//MARK: - AppFont相关


func FONT(font: CGFloat) -> UIFont {

return UIFont.systemFont(ofSize: font)

}

func FONT_BOLD(font: CGFloat) -> UIFont {

return UIFont.boldSystemFont(ofSize: font)

}


public enum AppFont {
static let font10 = FONT(font: 10)

static let font11 = FONT(font: 11)

static let font12 = FONT(font: 12)
static let font13 = FONT(font: 13)

static let font14 = FONT(font: 14)
static let font16 = FONT(font: 16)

static let font14_Blod = FONT_BOLD(font: 14)
static let font16_Blod = FONT_BOLD(font: 16)
static let font18_Blod = FONT_BOLD(font: 18)


}

// MARK: ============================================================================
// MARK: 界面UI固定尺寸

//MARK: - AppSize 相关
public enum AppSize {
static let margin = 10
}
微信打赏

赞赏是不耍流氓的鼓励