@@ -21,7 +21,11 @@ class ToastView: UIView {
21
21
private lazy var label : UILabel = {
22
22
let label = UILabel ( )
23
23
label. text = " "
24
- label. textColor = . white
24
+ if #available( iOS 13 . 0 , * ) {
25
+ label. textColor = . label
26
+ } else {
27
+ label. textColor = . white
28
+ }
25
29
label. font = . systemFont( ofSize: 14 )
26
30
label. numberOfLines = 0
27
31
label. preferredMaxLayoutWidth = UIScreen . main. bounds. width - 60
@@ -66,9 +70,13 @@ class ToastView: UIView {
66
70
static func showWait( text: String , view: UIView ? = nil ) {
67
71
DispatchQueue . main. async {
68
72
self . currentToastView? . removeFromSuperview ( )
73
+ var textColor : UIColor = . white
74
+ if #available( iOS 13 . 0 , * ) {
75
+ textColor = . label
76
+ }
69
77
let toastView = show ( text: text,
70
78
tagImage: nil ,
71
- textColor: . white ,
79
+ textColor: textColor ,
72
80
font: nil ,
73
81
postion: . center,
74
82
view: view)
@@ -92,8 +100,12 @@ class ToastView: UIView {
92
100
93
101
static func show( text: String , duration: CGFloat = 2.5 , view: UIView ? = nil ) {
94
102
DispatchQueue . main. async {
103
+ var textColor : UIColor = . white
104
+ if #available( iOS 13 . 0 , * ) {
105
+ textColor = . label
106
+ }
95
107
let toastView = show ( text: text, tagImage: nil ,
96
- textColor: . white , font: nil ,
108
+ textColor: textColor , font: nil ,
97
109
postion: . center,
98
110
view: view)
99
111
showAnimation ( toastView: toastView, duration: duration)
@@ -102,8 +114,12 @@ class ToastView: UIView {
102
114
103
115
static func show( text: String , postion: ToastViewPostion = . center) {
104
116
DispatchQueue . main. async {
117
+ var textColor : UIColor = . white
118
+ if #available( iOS 13 . 0 , * ) {
119
+ textColor = . label
120
+ }
105
121
let toastView = show ( text: text, tagImage: nil ,
106
- textColor: . white , font: nil ,
122
+ textColor: textColor , font: nil ,
107
123
postion: postion,
108
124
view: nil )
109
125
showAnimation ( toastView: toastView)
@@ -115,8 +131,12 @@ class ToastView: UIView {
115
131
duration: CGFloat = 2.5 ,
116
132
view: UIView ? = nil ) {
117
133
DispatchQueue . main. async {
134
+ var textColor : UIColor = . white
135
+ if #available( iOS 13 . 0 , * ) {
136
+ textColor = . label
137
+ }
118
138
let toastView = show ( text: text, tagImage: nil ,
119
- textColor: . white , font: nil ,
139
+ textColor: textColor , font: nil ,
120
140
postion: postion,
121
141
view: view)
122
142
showAnimation ( toastView: toastView, duration: duration)
@@ -125,8 +145,12 @@ class ToastView: UIView {
125
145
126
146
static func show( text: String , tagImage: UIImage ? = nil , postion: ToastViewPostion = . center, view: UIView ? = nil ) {
127
147
DispatchQueue . main. async {
148
+ var textColor : UIColor = . white
149
+ if #available( iOS 13 . 0 , * ) {
150
+ textColor = . label
151
+ }
128
152
let toastView = show ( text: text, tagImage: tagImage,
129
- textColor: . white , font: nil ,
153
+ textColor: textColor , font: nil ,
130
154
postion: postion,
131
155
view: view)
132
156
0 commit comments