NSObject+CNLiveConfigModuleInline.swift
3.87 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
//
// CNLiveConfigModuleInline.swift
// metaCode
//
// Created by open on 2023/11/2.
//
import Foundation
///!!!: pragma mark - 检测是否是iPhoneX系列
/**判断是否是iPhone X系列*/
var isiPhoneXSeries: Bool {
if #available(iOS 11, *) {
guard let w = UIApplication.shared.delegate?.window, let unwrapedWindow = w else {
return false
}
if unwrapedWindow.safeAreaInsets.left > 0 || unwrapedWindow.safeAreaInsets.bottom > 0 {
print(unwrapedWindow.safeAreaInsets)
return true
}
}
return false
}
/**获取系统状态栏高度**/
var getSystemStatusBarHeight: CGFloat {
return isiPhoneXSeries ? 44 : 20
}
/** 获取系统导航高度**/
var getSystemNavHeight: CGFloat {
return isiPhoneXSeries ? (44+44) : 64
}
/**获取系统导航UI高度*/
var getSystemNavUiHeight: CGFloat {
return get_system_nav_height() - get_system_statusBar_height()
}
/**获取系统tabbar高度*/
var getSystemTabbarHeight: CGFloat {
return is_iPhoneX_series() ? 83 : 49
}
/**获取系统tabbarUI高度*/
var getSystemTabbarUiHeight: CGFloat {
return 49
}
/**获取系统tabbarUI增加的高度 (因iPhoneX系列底部有安全区域增加的高度)*/
var getSystemTabbarUiOffsetHeight: CGFloat {
return get_system_tabbar_height() - get_system_tabbar_ui_height()
}
///!!!: #pragma mark - 字体
/**细体*/
func thin_font(pointSize: CGFloat) -> UIFont {
if #available(iOS 8.2, *) {
return UIFont.systemFont(ofSize: pointSize, weight: .thin)
}else {
return UIFont.systemFont(ofSize: pointSize)
}
}
/**半细体*/
func light_font(pointSize: CGFloat) -> UIFont {
if #available(iOS 8.2, *) {
return UIFont.systemFont(ofSize: pointSize, weight: .light)
}else {
return UIFont.systemFont(ofSize: pointSize)
}
}
/**正常体*/
func regular_font(pointSize: CGFloat) -> UIFont {
if #available(iOS 8.2, *) {
return UIFont.systemFont(ofSize: pointSize, weight: .regular)
}else {
return UIFont.systemFont(ofSize: pointSize)
}
}
/**半粗体*/
func medium_font(pointSize: CGFloat) -> UIFont {
if #available(iOS 8.2, *) {
return UIFont.systemFont(ofSize: pointSize, weight: .medium)
}else {
return UIFont.systemFont(ofSize: pointSize)
}
}
/**粗体*/
func semibold_font(pointSize: CGFloat) -> UIFont {
if #available(iOS 8.2, *) {
return UIFont.systemFont(ofSize: pointSize, weight: .semibold)
}else {
return UIFont.systemFont(ofSize: pointSize)
}
}
///!!!: #pragma mark - 自适应字体
/**细体(自适应)*/
func thin_adapt_font(pointSize: CGFloat) -> UIFont {
let multiple = UIScreen.main.bounds.size.width / 375
let size = floor(pointSize*multiple)
return thin_font(pointSize: size)
}
/**半细体(自适应)*/
func light_adapt_font(pointSize: CGFloat) -> UIFont {
let multiple = UIScreen.main.bounds.size.width / 375
let size = floor(pointSize*multiple)
return light_font(pointSize: size)
}
/**正常体(自适应)*/
func regular_adapt_font(pointSize: CGFloat) -> UIFont {
let multiple = UIScreen.main.bounds.size.width / 375
let size = floor(pointSize*multiple)
return regular_font(pointSize: size)
}
/**半粗体(自适应)*/
func medium_adapt_font(pointSize: CGFloat) -> UIFont {
let multiple = UIScreen.main.bounds.size.width / 375
let size = floor(pointSize*multiple)
return medium_font(pointSize: size)
}
/**粗体(自适应)*/
func semibold_adapt_font(pointSize: CGFloat) -> UIFont {
let multiple = UIScreen.main.bounds.size.width / 375
let size = floor(pointSize*multiple)
return semibold_font(pointSize: size)
}
///!!!: #pragma mark - 自适应长度
func adapt_length(length: CGFloat) -> CGFloat {
let multiple = UIScreen.main.bounds.size.width / 375
let f_adapt_length = floor(length * multiple)
return f_adapt_length
}