Commit 7b7581e89d58ceb7612b6692e70fd4ae25f034cb

Authored by Trịnh Văn Quân
1 parent be292bf5c7
Exists in master

Fixed: 2348, 2349

Showing 8 changed files with 440 additions and 259 deletions Side-by-side Diff

App/Base.lproj/Main.storyboard
... ... @@ -1497,7 +1497,7 @@
1497 1497 <rect key="frame" x="0.0" y="28" width="359" height="95"/>
1498 1498 <autoresizingMask key="autoresizingMask"/>
1499 1499 <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="kuK-gD-GMp" id="I5B-Nz-L9y">
1500   - <rect key="frame" x="0.0" y="0.0" width="359" height="95"/>
  1500 + <rect key="frame" x="0.0" y="0.0" width="359" height="94"/>
1501 1501 <autoresizingMask key="autoresizingMask"/>
1502 1502 <subviews>
1503 1503 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="DL2-8a-uPN" customClass="UIViewCustom" customModule="GeneralUtils">
... ... @@ -2287,7 +2287,7 @@
2287 2287 <rect key="frame" x="0.0" y="28" width="315" height="44"/>
2288 2288 <autoresizingMask key="autoresizingMask"/>
2289 2289 <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="nHp-pE-xAT" id="ONP-wK-o5X">
2290   - <rect key="frame" x="0.0" y="0.0" width="315" height="44"/>
  2290 + <rect key="frame" x="0.0" y="0.0" width="315" height="43"/>
2291 2291 <autoresizingMask key="autoresizingMask"/>
2292 2292 <subviews>
2293 2293 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="6eU-CX-rj2">
App/camera/board/Board.swift
... ... @@ -77,6 +77,9 @@
77 77 }
78 78  
79 79 @IBAction func dateClick(_ sender: Any) {
  80 + if isReadOnly {
  81 + return;
  82 + }
80 83 DatePickerDialog().show("撮影日", datePickerMode: .date, callback: { date in
81 84 if let date = date {
82 85 self.setDate(date: date)
App/commons/CellMucChupWithCamera.swift
... ... @@ -89,7 +89,6 @@
89 89 }
90 90  
91 91 //region upload =======
92   - //TODO: Them 2 field date: String, note: String?
93 92 fileprivate func uploadImage(id: Int, signboard: Int, date: Double?, note: String?, data: Data) {
94 93 let tvProgress = SwiftOverlays.showBlockingWaitOverlayWithText(LocalizedString("Uploading") + ".....")
95 94 Alamofire.upload(multipartFormData: { (multipartFormData: MultipartFormData) in
... ... @@ -116,7 +115,13 @@
116 115 if let value = response.result.value {
117 116 let json = JSON.parse(value)
118 117 if let isSuccess = json["isSuccess"].bool, isSuccess, let url = json["url"].string {
119   - self.shootItem.addImg(img: ImgObj(url: url, signboard: signboard, date: nil, note: nil))
  118 + var dateInt: Int?;
  119 + if let date = date {
  120 + dateInt = Int(date)
  121 + } else {
  122 + dateInt = nil;
  123 + }
  124 + self.shootItem.addImg(img: ImgObj(url: url, signboard: signboard, date: dateInt, note: note))
120 125 CommonUtils.showToastLong(text: LocalizedString("successful"))
121 126 return
122 127 }
App/listCtruong/VCShootItemList.swift
... ... @@ -65,6 +65,7 @@
65 65 func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
66 66 }
67 67 //endregion
  68 +
68 69 override var prefersStatusBarHidden: Bool {
69 70 return true
70 71 }
GeneralUtils/GeneralUtils.xcodeproj/project.xcworkspace/xcuserdata/ptran.xcuserdatad/UserInterfaceState.xcuserstate
No preview for this file type
GeneralUtils/GeneralUtils/libs/SCLAlertView/SCLAlertView.swift
Changes suppressed. Click to show
... ... @@ -9,30 +9,30 @@
9 9 import Foundation
10 10 import UIKit
11 11 fileprivate func < <T : Comparable>(lhs: T?, rhs: T?) -> Bool {
12   - switch (lhs, rhs) {
13   - case let (l?, r?):
14   - return l < r
15   - case (nil, _?):
16   - return true
17   - default:
18   - return false
19   - }
  12 + switch (lhs, rhs) {
  13 + case let (l?, r?):
  14 + return l < r
  15 + case (nil, _?):
  16 + return true
  17 + default:
  18 + return false
  19 + }
20 20 }
21 21  
22 22 fileprivate func > <T : Comparable>(lhs: T?, rhs: T?) -> Bool {
23   - switch (lhs, rhs) {
24   - case let (l?, r?):
25   - return l > r
26   - default:
27   - return rhs < lhs
28   - }
  23 + switch (lhs, rhs) {
  24 + case let (l?, r?):
  25 + return l > r
  26 + default:
  27 + return rhs < lhs
  28 + }
29 29 }
30 30  
31 31  
32 32 // Pop Up Styles
33 33 public enum SCLAlertViewStyle {
34   - case success, error, notice, warning, info, edit, wait
35   -
  34 + case success, error, notice, warning, info, edit, wait, question
  35 +
36 36 var defaultColorInt: UInt {
37 37 switch self {
38 38 case .success:
39 39  
... ... @@ -49,8 +49,10 @@
49 49 return 0xA429FF
50 50 case .wait:
51 51 return 0xD62DA5
  52 + case .question:
  53 + return 0x727375
52 54 }
53   -
  55 +
54 56 }
55 57  
56 58 }
57 59  
58 60  
... ... @@ -74,16 +76,26 @@
74 76 var customBackgroundColor:UIColor?
75 77 var customTextColor:UIColor?
76 78 var initialTitle:String!
77   - var showDurationStatus:Bool=false
78   -
  79 + var showTimeout:ShowTimeoutConfiguration?
  80 +
  81 + public struct ShowTimeoutConfiguration {
  82 + let prefix: String
  83 + let suffix: String
  84 +
  85 + public init(prefix: String = "", suffix: String = "") {
  86 + self.prefix = prefix
  87 + self.suffix = suffix
  88 + }
  89 + }
  90 +
79 91 public init() {
80 92 super.init(frame: CGRect.zero)
81 93 }
82   -
  94 +
83 95 required public init?(coder aDecoder: NSCoder) {
84 96 super.init(coder:aDecoder)
85 97 }
86   -
  98 +
87 99 override public init(frame:CGRect) {
88 100 super.init(frame:frame)
89 101 }
90 102  
91 103  
92 104  
93 105  
94 106  
95 107  
... ... @@ -93,36 +105,38 @@
93 105 // Example: SCLAlertView().showSuccess(self, title: "Test", subTitle: "Value").close()
94 106 open class SCLAlertViewResponder {
95 107 let alertview: SCLAlertView
96   -
  108 +
97 109 // Initialisation and Title/Subtitle/Close functions
98 110 public init(alertview: SCLAlertView) {
99 111 self.alertview = alertview
100 112 }
101   -
  113 +
102 114 open func setTitle(_ title: String) {
103 115 self.alertview.labelTitle.text = title
104 116 }
105   -
  117 +
106 118 open func setSubTitle(_ subTitle: String) {
107 119 self.alertview.viewText.text = subTitle
108 120 }
109   -
  121 +
110 122 open func close() {
111 123 self.alertview.hideView()
112 124 }
113   -
  125 +
114 126 open func setDismissBlock(_ dismissBlock: @escaping DismissBlock) {
115 127 self.alertview.dismissBlock = dismissBlock
116 128 }
117 129 }
118 130  
119 131 let kCircleHeightBackground: CGFloat = 62.0
  132 +let uniqueTag: Int = Int(arc4random())
  133 +let uniqueAccessibilityIdentifier: String = "SCLAlertView"
120 134  
121 135 public typealias DismissBlock = () -> Void
122 136  
123 137 // The Main Class
124 138 open class SCLAlertView: UIViewController {
125   -
  139 +
126 140 public struct SCLAppearance {
127 141 let kDefaultShadowOpacity: CGFloat
128 142 let kCircleTopPosition: CGFloat
129 143  
130 144  
131 145  
132 146  
133 147  
134 148  
... ... @@ -131,34 +145,38 @@
131 145 let kCircleIconHeight: CGFloat
132 146 let kTitleTop:CGFloat
133 147 let kTitleHeight:CGFloat
  148 + let kTitleMinimumScaleFactor: CGFloat
134 149 let kWindowWidth: CGFloat
135 150 var kWindowHeight: CGFloat
136 151 var kTextHeight: CGFloat
137 152 let kTextFieldHeight: CGFloat
138 153 let kTextViewdHeight: CGFloat
139 154 let kButtonHeight: CGFloat
  155 + let circleBackgroundColor: UIColor
140 156 let contentViewColor: UIColor
141 157 let contentViewBorderColor: UIColor
142 158 let titleColor: UIColor
143   -
  159 +
144 160 // Fonts
145 161 let kTitleFont: UIFont
146 162 let kTextFont: UIFont
147 163 let kButtonFont: UIFont
148   -
  164 +
149 165 // UI Options
  166 + var disableTapGesture: Bool
150 167 var showCloseButton: Bool
151 168 var showCircularIcon: Bool
152 169 var shouldAutoDismiss: Bool // Set this false to 'Disable' Auto hideView when SCLButton is tapped
153 170 var contentViewCornerRadius : CGFloat
154 171 var fieldCornerRadius : CGFloat
155 172 var buttonCornerRadius : CGFloat
156   -
  173 + var dynamicAnimatorActive : Bool
  174 +
157 175 // Actions
158 176 var hideWhenBackgroundViewIsTapped: Bool
159   -
160   - public init(kDefaultShadowOpacity: CGFloat = 0.7, kCircleTopPosition: CGFloat = -12.0, kCircleBackgroundTopPosition: CGFloat = -15.0, kCircleHeight: CGFloat = 56.0, kCircleIconHeight: CGFloat = 20.0, kTitleTop:CGFloat = 30.0, kTitleHeight:CGFloat = 25.0, kWindowWidth: CGFloat = 240.0, kWindowHeight: CGFloat = 178.0, kTextHeight: CGFloat = 90.0, kTextFieldHeight: CGFloat = 45.0, kTextViewdHeight: CGFloat = 80.0, kButtonHeight: CGFloat = 45.0, kTitleFont: UIFont = UIFont.systemFont(ofSize: 20), kTextFont: UIFont = UIFont.systemFont(ofSize: 14), kButtonFont: UIFont = UIFont.boldSystemFont(ofSize: 14), showCloseButton: Bool = true, showCircularIcon: Bool = true, shouldAutoDismiss: Bool = true, contentViewCornerRadius: CGFloat = 5.0, fieldCornerRadius: CGFloat = 3.0, buttonCornerRadius: CGFloat = 3.0, hideWhenBackgroundViewIsTapped: Bool = false, contentViewColor: UIColor = UIColorFromRGB(0xFFFFFF), contentViewBorderColor: UIColor = UIColorFromRGB(0xCCCCCC), titleColor: UIColor = UIColorFromRGB(0x4D4D4D)) {
161   -
  177 +
  178 + public init(kDefaultShadowOpacity: CGFloat = 0.7, kCircleTopPosition: CGFloat = 0.0, kCircleBackgroundTopPosition: CGFloat = 6.0, kCircleHeight: CGFloat = 56.0, kCircleIconHeight: CGFloat = 20.0, kTitleTop:CGFloat = 30.0, kTitleHeight:CGFloat = 25.0, kWindowWidth: CGFloat = 240.0, kWindowHeight: CGFloat = 178.0, kTextHeight: CGFloat = 90.0, kTextFieldHeight: CGFloat = 45.0, kTextViewdHeight: CGFloat = 80.0, kButtonHeight: CGFloat = 45.0, kTitleFont: UIFont = UIFont.systemFont(ofSize: 20), kTitleMinimumScaleFactor: CGFloat = 1.0, kTextFont: UIFont = UIFont.systemFont(ofSize: 14), kButtonFont: UIFont = UIFont.boldSystemFont(ofSize: 14), showCloseButton: Bool = true, showCircularIcon: Bool = true, shouldAutoDismiss: Bool = true, contentViewCornerRadius: CGFloat = 5.0, fieldCornerRadius: CGFloat = 3.0, buttonCornerRadius: CGFloat = 3.0, hideWhenBackgroundViewIsTapped: Bool = false, circleBackgroundColor: UIColor = UIColor.white, contentViewColor: UIColor = UIColorFromRGB(0xFFFFFF), contentViewBorderColor: UIColor = UIColorFromRGB(0xCCCCCC), titleColor: UIColor = UIColorFromRGB(0x4D4D4D), dynamicAnimatorActive: Bool = false, disableTapGesture: Bool = false ) {
  179 +
162 180 self.kDefaultShadowOpacity = kDefaultShadowOpacity
163 181 self.kCircleTopPosition = kCircleTopPosition
164 182 self.kCircleBackgroundTopPosition = kCircleBackgroundTopPosition
165 183  
166 184  
167 185  
168 186  
169 187  
170 188  
171 189  
172 190  
173 191  
174 192  
175 193  
176 194  
... ... @@ -172,44 +190,64 @@
172 190 self.kTextFieldHeight = kTextFieldHeight
173 191 self.kTextViewdHeight = kTextViewdHeight
174 192 self.kButtonHeight = kButtonHeight
  193 + self.circleBackgroundColor = circleBackgroundColor
175 194 self.contentViewColor = contentViewColor
176 195 self.contentViewBorderColor = contentViewBorderColor
177 196 self.titleColor = titleColor
178   -
  197 +
179 198 self.kTitleFont = kTitleFont
  199 + self.kTitleMinimumScaleFactor = kTitleMinimumScaleFactor
180 200 self.kTextFont = kTextFont
181 201 self.kButtonFont = kButtonFont
182   -
  202 +
  203 + self.disableTapGesture = disableTapGesture
183 204 self.showCloseButton = showCloseButton
184 205 self.showCircularIcon = showCircularIcon
185 206 self.shouldAutoDismiss = shouldAutoDismiss
186 207 self.contentViewCornerRadius = contentViewCornerRadius
187 208 self.fieldCornerRadius = fieldCornerRadius
188 209 self.buttonCornerRadius = buttonCornerRadius
189   -
  210 +
190 211 self.hideWhenBackgroundViewIsTapped = hideWhenBackgroundViewIsTapped
  212 + self.dynamicAnimatorActive = dynamicAnimatorActive
191 213 }
192   -
  214 +
193 215 mutating func setkWindowHeight(_ kWindowHeight:CGFloat) {
194 216 self.kWindowHeight = kWindowHeight
195 217 }
196   -
  218 +
197 219 mutating func setkTextHeight(_ kTextHeight:CGFloat) {
198 220 self.kTextHeight = kTextHeight
199 221 }
200 222 }
201   -
  223 +
  224 + public struct SCLTimeoutConfiguration {
  225 +
  226 + public typealias ActionType = () -> Void
  227 +
  228 + var value: TimeInterval
  229 + let action: ActionType
  230 +
  231 + mutating func increaseValue(by: Double) {
  232 + self.value = value + by
  233 + }
  234 +
  235 + public init(timeoutValue: TimeInterval, timeoutAction: @escaping ActionType) {
  236 + self.value = timeoutValue
  237 + self.action = timeoutAction
  238 + }
  239 +
  240 + }
  241 +
202 242 var appearance: SCLAppearance!
203   -
  243 +
204 244 // UI Colour
205 245 var viewColor = UIColor()
206   -
  246 +
207 247 // UI Options
208 248 open var iconTintColor: UIColor?
209 249 open var customSubview : UIView?
210   -
211 250  
212   -
213 251 // Members declaration
214 252 var baseView = UIView()
215 253 var labelTitle = UILabel()
216 254  
217 255  
218 256  
219 257  
220 258  
... ... @@ -218,36 +256,36 @@
218 256 var circleBG = UIView(frame:CGRect(x:0, y:0, width:kCircleHeightBackground, height:kCircleHeightBackground))
219 257 var circleView = UIView()
220 258 var circleIconView : UIView?
221   - var duration: TimeInterval!
222   - var durationStatusTimer: Timer!
223   - var durationTimer: Timer!
  259 + var timeout: SCLTimeoutConfiguration?
  260 + var showTimeoutTimer: Timer?
  261 + var timeoutTimer: Timer?
224 262 var dismissBlock : DismissBlock?
225 263 fileprivate var inputs = [UITextField]()
226 264 fileprivate var input = [UITextView]()
227 265 internal var buttons = [SCLButton]()
228 266 fileprivate var selfReference: SCLAlertView?
229   -
  267 +
230 268 public init(appearance: SCLAppearance) {
231 269 self.appearance = appearance
232 270 super.init(nibName:nil, bundle:nil)
233 271 setup()
234 272 }
235   -
  273 +
236 274 required public init?(coder aDecoder: NSCoder) {
237 275 fatalError("NSCoding not supported")
238 276 }
239   -
  277 +
240 278 required public init() {
241 279 appearance = SCLAppearance()
242 280 super.init(nibName:nil, bundle:nil)
243 281 setup()
244 282 }
245   -
  283 +
246 284 override public init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
247 285 appearance = SCLAppearance()
248 286 super.init(nibName:nibNameOrNil, bundle:nibBundleOrNil)
249 287 }
250   -
  288 +
251 289 fileprivate func setup() {
252 290 // Set up main view
253 291 view.frame = UIScreen.main.bounds
254 292  
255 293  
256 294  
... ... @@ -264,17 +302,21 @@
264 302 contentView.addSubview(labelTitle)
265 303 contentView.addSubview(viewText)
266 304 // Circle View
267   - circleBG.backgroundColor = UIColor.white
  305 + circleBG.backgroundColor = appearance.circleBackgroundColor
268 306 circleBG.layer.cornerRadius = circleBG.frame.size.height / 2
269 307 baseView.addSubview(circleBG)
270 308 circleBG.addSubview(circleView)
271 309 let x = (kCircleHeightBackground - appearance.kCircleHeight) / 2
272   - circleView.frame = CGRect(x:x, y:x, width:appearance.kCircleHeight, height:appearance.kCircleHeight)
  310 + circleView.frame = CGRect(x:x, y:x+appearance.kCircleTopPosition, width:appearance.kCircleHeight, height:appearance.kCircleHeight)
273 311 circleView.layer.cornerRadius = circleView.frame.size.height / 2
274 312 // Title
275   - labelTitle.numberOfLines = 1
  313 + labelTitle.numberOfLines = 0
276 314 labelTitle.textAlignment = .center
277 315 labelTitle.font = appearance.kTitleFont
  316 + if(appearance.kTitleMinimumScaleFactor < 1){
  317 + labelTitle.minimumScaleFactor = appearance.kTitleMinimumScaleFactor
  318 + labelTitle.adjustsFontSizeToFitWidth = true
  319 + }
278 320 labelTitle.frame = CGRect(x:12, y:appearance.kTitleTop, width: appearance.kWindowWidth - 24, height:appearance.kTitleHeight)
279 321 // View text
280 322 viewText.isEditable = false
281 323  
282 324  
283 325  
284 326  
285 327  
286 328  
... ... @@ -289,31 +331,43 @@
289 331 viewText.textColor = appearance.titleColor
290 332 contentView.layer.borderColor = appearance.contentViewBorderColor.cgColor
291 333 //Gesture Recognizer for tapping outside the textinput
292   - let tapGesture = UITapGestureRecognizer(target: self, action: #selector(SCLAlertView.tapped(_:)))
293   - tapGesture.numberOfTapsRequired = 1
294   - self.view.addGestureRecognizer(tapGesture)
  334 + if appearance.disableTapGesture == false {
  335 + let tapGesture = UITapGestureRecognizer(target: self, action: #selector(SCLAlertView.tapped(_:)))
  336 + tapGesture.numberOfTapsRequired = 1
  337 + self.view.addGestureRecognizer(tapGesture)
  338 + }
295 339 }
296   -
  340 +
297 341 override open func viewWillLayoutSubviews() {
298 342 super.viewWillLayoutSubviews()
299 343 let rv = UIApplication.shared.keyWindow! as UIWindow
300 344 let sz = rv.frame.size
301   -
  345 +
302 346 // Set background frame
303 347 view.frame.size = sz
304   -
  348 +
  349 + let hMargin: CGFloat = 12
  350 +
  351 + // get actual height of title text
  352 + var titleActualHeight: CGFloat = 0
  353 + if let title = labelTitle.text {
  354 + titleActualHeight = title.heightWithConstrainedWidth(width: appearance.kWindowWidth - hMargin * 2, font: labelTitle.font) + 10
  355 + // get the larger height for the title text
  356 + titleActualHeight = (titleActualHeight > appearance.kTitleHeight ? titleActualHeight : appearance.kTitleHeight)
  357 + }
  358 +
305 359 // computing the right size to use for the textView
306 360 let maxHeight = sz.height - 100 // max overall height
307 361 var consumedHeight = CGFloat(0)
308   - consumedHeight += appearance.kTitleTop + appearance.kTitleHeight
  362 + consumedHeight += (titleActualHeight > 0 ? appearance.kTitleTop + titleActualHeight : hMargin)
309 363 consumedHeight += 14
310 364 consumedHeight += appearance.kButtonHeight * CGFloat(buttons.count)
311 365 consumedHeight += appearance.kTextFieldHeight * CGFloat(inputs.count)
312 366 consumedHeight += appearance.kTextViewdHeight * CGFloat(input.count)
313 367 let maxViewTextHeight = maxHeight - consumedHeight
314   - let viewTextWidth = appearance.kWindowWidth - 24
  368 + let viewTextWidth = appearance.kWindowWidth - hMargin * 2
315 369 var viewTextHeight = appearance.kTextHeight
316   -
  370 +
317 371 // Check if there is a custom subview and add it over the textview
318 372 if let customSubview = customSubview {
319 373 viewTextHeight = min(customSubview.frame.height, maxViewTextHeight)
... ... @@ -323,7 +377,7 @@
323 377 // computing the right size to use for the textView
324 378 let suggestedViewTextSize = viewText.sizeThatFits(CGSize(width: viewTextWidth, height: CGFloat.greatestFiniteMagnitude))
325 379 viewTextHeight = min(suggestedViewTextSize.height, maxViewTextHeight)
326   -
  380 +
327 381 // scroll management
328 382 if (suggestedViewTextSize.height > maxViewTextHeight) {
329 383 viewText.isScrollEnabled = true
... ... @@ -331,7 +385,7 @@
331 385 viewText.isScrollEnabled = false
332 386 }
333 387 }
334   -
  388 +
335 389 let windowHeight = consumedHeight + viewTextHeight
336 390 // Set frames
337 391 var x = (sz.width - appearance.kWindowWidth) / 2
338 392  
339 393  
340 394  
341 395  
342 396  
343 397  
344 398  
345 399  
346 400  
... ... @@ -340,54 +394,54 @@
340 394 contentView.layer.cornerRadius = appearance.contentViewCornerRadius
341 395 y -= kCircleHeightBackground * 0.6
342 396 x = (sz.width - kCircleHeightBackground) / 2
343   - circleBG.frame = CGRect(x:x, y:y+6, width:kCircleHeightBackground, height:kCircleHeightBackground)
344   -
  397 + circleBG.frame = CGRect(x:x, y:y+appearance.kCircleBackgroundTopPosition, width:kCircleHeightBackground, height:kCircleHeightBackground)
  398 +
345 399 //adjust Title frame based on circularIcon show/hide flag
346 400 let titleOffset : CGFloat = appearance.showCircularIcon ? 0.0 : -12.0
347 401 labelTitle.frame = labelTitle.frame.offsetBy(dx: 0, dy: titleOffset)
348   -
  402 +
349 403 // Subtitle
350   - y = appearance.kTitleTop + appearance.kTitleHeight + titleOffset
351   - viewText.frame = CGRect(x:12, y:y, width: appearance.kWindowWidth - 24, height:appearance.kTextHeight)
352   - viewText.frame = CGRect(x:12, y:y, width: viewTextWidth, height:viewTextHeight)
  404 + y = titleActualHeight > 0 ? appearance.kTitleTop + titleActualHeight + titleOffset : hMargin
  405 + viewText.frame = CGRect(x:hMargin, y:y, width: appearance.kWindowWidth - hMargin * 2, height:appearance.kTextHeight)
  406 + viewText.frame = CGRect(x:hMargin, y:y, width: viewTextWidth, height:viewTextHeight)
353 407 // Text fields
354 408 y += viewTextHeight + 14.0
355 409 for txt in inputs {
356   - txt.frame = CGRect(x:12, y:y, width:appearance.kWindowWidth - 24, height:30)
  410 + txt.frame = CGRect(x:hMargin, y:y, width:appearance.kWindowWidth - hMargin * 2, height:30)
357 411 txt.layer.cornerRadius = appearance.fieldCornerRadius
358 412 y += appearance.kTextFieldHeight
359 413 }
360 414 for txt in input {
361   - txt.frame = CGRect(x:12, y:y, width:appearance.kWindowWidth - 24, height:70)
  415 + txt.frame = CGRect(x:hMargin, y:y, width:appearance.kWindowWidth - hMargin * 2, height:70)
362 416 //txt.layer.cornerRadius = fieldCornerRadius
363 417 y += appearance.kTextViewdHeight
364 418 }
365 419 // Buttons
366 420 for btn in buttons {
367   - btn.frame = CGRect(x:12, y:y, width:appearance.kWindowWidth - 24, height:35)
  421 + btn.frame = CGRect(x:hMargin, y:y, width:appearance.kWindowWidth - hMargin * 2, height:35)
368 422 btn.layer.cornerRadius = appearance.buttonCornerRadius
369 423 y += appearance.kButtonHeight
370 424 }
371 425 }
372   -
  426 +
373 427 override open func viewDidAppear(_ animated: Bool) {
374 428 super.viewDidAppear(animated)
375 429 NotificationCenter.default.addObserver(self, selector: #selector(SCLAlertView.keyboardWillShow(_:)), name:NSNotification.Name.UIKeyboardWillShow, object: nil);
376 430 NotificationCenter.default.addObserver(self, selector: #selector(SCLAlertView.keyboardWillHide(_:)), name:NSNotification.Name.UIKeyboardWillHide, object: nil);
377 431 }
378   -
  432 +
379 433 open override func viewDidDisappear(_ animated: Bool) {
380 434 super.viewDidDisappear(animated)
381 435 NotificationCenter.default.removeObserver(self, name: NSNotification.Name.UIKeyboardWillShow, object: nil)
382 436 NotificationCenter.default.removeObserver(self, name: NSNotification.Name.UIKeyboardWillHide, object: nil)
383 437 }
384   -
  438 +
385 439 override open func touchesEnded(_ touches:Set<UITouch>, with event:UIEvent?) {
386 440 if event?.touches(for: view)?.count > 0 {
387 441 view.endEditing(true)
388 442 }
389 443 }
390   -
  444 +
391 445 open func addTextField(_ title:String?=nil)->UITextField {
392 446 // Update view height
393 447 appearance.setkWindowHeight(appearance.kWindowHeight + appearance.kTextFieldHeight)
394 448  
... ... @@ -406,13 +460,13 @@
406 460 inputs.append(txt)
407 461 return txt
408 462 }
409   -
  463 +
410 464 open func addTextView()->UITextView {
411 465 // Update view height
412 466 appearance.setkWindowHeight(appearance.kWindowHeight + appearance.kTextViewdHeight)
413 467 // Add text view
414 468 let txt = UITextView()
415   - // No placeholder with UITextView but you can use KMPlaceholderTextView library
  469 + // No placeholder with UITextView but you can use KMPlaceholderTextView library
416 470 txt.font = appearance.kTextFont
417 471 //txt.autocapitalizationType = UITextAutocapitalizationType.Words
418 472 //txt.clearButtonMode = UITextFieldViewMode.WhileEditing
419 473  
... ... @@ -422,10 +476,10 @@
422 476 input.append(txt)
423 477 return txt
424 478 }
425   -
  479 +
426 480 @discardableResult
427   - open func addButton(_ title:String, backgroundColor:UIColor? = nil, textColor:UIColor? = nil, showDurationStatus:Bool=false, action:@escaping ()->Void)->SCLButton {
428   - let btn = addButton(title, backgroundColor: backgroundColor, textColor: textColor, showDurationStatus: showDurationStatus)
  481 + open func addButton(_ title:String, backgroundColor:UIColor? = nil, textColor:UIColor? = nil, showTimeout:SCLButton.ShowTimeoutConfiguration? = nil, action:@escaping ()->Void)->SCLButton {
  482 + let btn = addButton(title, backgroundColor: backgroundColor, textColor: textColor, showTimeout: showTimeout)
429 483 btn.actionType = SCLActionType.closure
430 484 btn.action = action
431 485 btn.addTarget(self, action:#selector(SCLAlertView.buttonTapped(_:)), for:.touchUpInside)
432 486  
... ... @@ -433,10 +487,10 @@
433 487 btn.addTarget(self, action:#selector(SCLAlertView.buttonRelease(_:)), for:[.touchUpInside, .touchUpOutside, .touchCancel, .touchDragOutside] )
434 488 return btn
435 489 }
436   -
  490 +
437 491 @discardableResult
438   - open func addButton(_ title:String, backgroundColor:UIColor? = nil, textColor:UIColor? = nil, showDurationStatus:Bool = false, target:AnyObject, selector:Selector)->SCLButton {
439   - let btn = addButton(title, backgroundColor: backgroundColor, textColor: textColor, showDurationStatus: showDurationStatus)
  492 + open func addButton(_ title:String, backgroundColor:UIColor? = nil, textColor:UIColor? = nil, showTimeout:SCLButton.ShowTimeoutConfiguration? = nil, target:AnyObject, selector:Selector)->SCLButton {
  493 + let btn = addButton(title, backgroundColor: backgroundColor, textColor: textColor, showTimeout: showTimeout)
440 494 btn.actionType = SCLActionType.selector
441 495 btn.target = target
442 496 btn.selector = selector
443 497  
... ... @@ -445,9 +499,9 @@
445 499 btn.addTarget(self, action:#selector(SCLAlertView.buttonRelease(_:)), for:[.touchUpInside, .touchUpOutside, .touchCancel, .touchDragOutside] )
446 500 return btn
447 501 }
448   -
  502 +
449 503 @discardableResult
450   - fileprivate func addButton(_ title:String, backgroundColor:UIColor? = nil, textColor:UIColor? = nil, showDurationStatus:Bool=false)->SCLButton {
  504 + fileprivate func addButton(_ title:String, backgroundColor:UIColor? = nil, textColor:UIColor? = nil, showTimeout:SCLButton.ShowTimeoutConfiguration? = nil)->SCLButton {
451 505 // Update view height
452 506 appearance.setkWindowHeight(appearance.kWindowHeight + appearance.kButtonHeight)
453 507 // Add button
454 508  
... ... @@ -458,12 +512,12 @@
458 512 btn.customBackgroundColor = backgroundColor
459 513 btn.customTextColor = textColor
460 514 btn.initialTitle = title
461   - btn.showDurationStatus = showDurationStatus
  515 + btn.showTimeout = showTimeout
462 516 contentView.addSubview(btn)
463 517 buttons.append(btn)
464 518 return btn
465 519 }
466   -
  520 +
467 521 func buttonTapped(_ btn:SCLButton) {
468 522 if btn.actionType == SCLActionType.closure {
469 523 btn.action()
470 524  
... ... @@ -473,11 +527,11 @@
473 527 } else {
474 528 print("Unknow action type for button")
475 529 }
476   -
  530 +
477 531 if(self.view.alpha != 0.0 && appearance.shouldAutoDismiss){ hideView() }
478 532 }
479   -
480   -
  533 +
  534 +
481 535 func buttonTapDown(_ btn:SCLButton) {
482 536 var hue : CGFloat = 0
483 537 var saturation : CGFloat = 0
484 538  
485 539  
486 540  
487 541  
488 542  
489 543  
490 544  
491 545  
... ... @@ -488,29 +542,29 @@
488 542 brightness = brightness * CGFloat(pressBrightnessFactor)
489 543 btn.backgroundColor = UIColor(hue: hue, saturation: saturation, brightness: brightness, alpha: alpha)
490 544 }
491   -
  545 +
492 546 func buttonRelease(_ btn:SCLButton) {
493 547 btn.backgroundColor = btn.customBackgroundColor ?? viewColor
494 548 }
495   -
  549 +
496 550 var tmpContentViewFrameOrigin: CGPoint?
497 551 var tmpCircleViewFrameOrigin: CGPoint?
498 552 var keyboardHasBeenShown:Bool = false
499   -
  553 +
500 554 func keyboardWillShow(_ notification: Notification) {
501 555 keyboardHasBeenShown = true
502   -
  556 +
503 557 guard let userInfo = (notification as NSNotification).userInfo else {return}
504 558 guard let endKeyBoardFrame = (userInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue.minY else {return}
505   -
  559 +
506 560 if tmpContentViewFrameOrigin == nil {
507   - tmpContentViewFrameOrigin = self.contentView.frame.origin
  561 + tmpContentViewFrameOrigin = self.contentView.frame.origin
508 562 }
509   -
  563 +
510 564 if tmpCircleViewFrameOrigin == nil {
511   - tmpCircleViewFrameOrigin = self.circleBG.frame.origin
  565 + tmpCircleViewFrameOrigin = self.circleBG.frame.origin
512 566 }
513   -
  567 +
514 568 var newContentViewFrameY = self.contentView.frame.maxY - endKeyBoardFrame
515 569 if newContentViewFrameY < 0 {
516 570 newContentViewFrameY = 0
... ... @@ -519,7 +573,7 @@
519 573 self.contentView.frame.origin.y -= newContentViewFrameY
520 574 self.circleBG.frame.origin.y = newBallViewFrameY
521 575 }
522   -
  576 +
523 577 func keyboardWillHide(_ notification: Notification) {
524 578 if(keyboardHasBeenShown){//This could happen on the simulator (keyboard will be hidden)
525 579 if(self.tmpContentViewFrameOrigin != nil){
526 580  
527 581  
528 582  
529 583  
530 584  
531 585  
532 586  
533 587  
534 588  
535 589  
536 590  
537 591  
538 592  
539 593  
540 594  
541 595  
542 596  
543 597  
544 598  
545 599  
546 600  
547 601  
548 602  
549 603  
550 604  
551 605  
552 606  
553 607  
554 608  
... ... @@ -530,97 +584,100 @@
530 584 self.circleBG.frame.origin.y = self.tmpCircleViewFrameOrigin!.y
531 585 self.tmpCircleViewFrameOrigin = nil
532 586 }
533   -
  587 +
534 588 keyboardHasBeenShown = false
535 589 }
536 590 }
537   -
  591 +
538 592 //Dismiss keyboard when tapped outside textfield & close SCLAlertView when hideWhenBackgroundViewIsTapped
539 593 func tapped(_ gestureRecognizer: UITapGestureRecognizer) {
540 594 self.view.endEditing(true)
541   -
  595 +
542 596 if let tappedView = gestureRecognizer.view , tappedView.hitTest(gestureRecognizer.location(in: tappedView), with: nil) == baseView && appearance.hideWhenBackgroundViewIsTapped {
543   -
  597 +
544 598 hideView()
545 599 }
546 600 }
547   -
  601 +
548 602 // showCustom(view, title, subTitle, UIColor, UIImage)
549   - open func showCustom(_ title: String, subTitle: String, color: UIColor, icon: UIImage, closeButtonTitle:String?=nil, duration:TimeInterval=0.0, colorStyle: UInt=SCLAlertViewStyle.success.defaultColorInt, colorTextButton: UInt=0xFFFFFF, circleIconImage: UIImage? = nil, animationStyle: SCLAnimationStyle = .topToBottom) -> SCLAlertViewResponder {
550   -
551   -
  603 + @discardableResult
  604 + open func showCustom(_ title: String, subTitle: String, color: UIColor, icon: UIImage, closeButtonTitle:String?=nil, timeout:SCLTimeoutConfiguration?=nil, colorStyle: UInt=SCLAlertViewStyle.success.defaultColorInt, colorTextButton: UInt=0xFFFFFF, circleIconImage: UIImage? = nil, animationStyle: SCLAnimationStyle = .topToBottom) -> SCLAlertViewResponder {
  605 +
  606 +
552 607 var red: CGFloat = 0, green: CGFloat = 0, blue: CGFloat = 0, alpha: CGFloat = 0
553   -
  608 +
554 609 color.getRed(&red, green: &green, blue: &blue, alpha: &alpha)
555   -
  610 +
556 611 var colorAsUInt32 : UInt32 = 0
557 612 colorAsUInt32 += UInt32(red * 255.0) << 16
558 613 colorAsUInt32 += UInt32(green * 255.0) << 8
559 614 colorAsUInt32 += UInt32(blue * 255.0)
560   -
  615 +
561 616 let colorAsUInt = UInt(colorAsUInt32)
562   -
563   - return showTitle(title, subTitle: subTitle, duration: duration, completeText:closeButtonTitle, style: .success, colorStyle: colorAsUInt, colorTextButton: colorTextButton, circleIconImage: icon, animationStyle: animationStyle)
  617 +
  618 + return showTitle(title, subTitle: subTitle, timeout: timeout, completeText:closeButtonTitle, style: .success, colorStyle: colorAsUInt, colorTextButton: colorTextButton, circleIconImage: icon, animationStyle: animationStyle)
564 619 }
565   -
  620 +
566 621 // showSuccess(view, title, subTitle)
567 622 @discardableResult
568   - open func showSuccess(_ title: String, subTitle: String, closeButtonTitle:String?=nil, duration:TimeInterval=0.0, colorStyle: UInt=SCLAlertViewStyle.success.defaultColorInt, colorTextButton: UInt=0xFFFFFF, circleIconImage: UIImage? = nil, animationStyle: SCLAnimationStyle = .topToBottom) -> SCLAlertViewResponder {
569   - return showTitle(title, subTitle: subTitle, duration: duration, completeText:closeButtonTitle, style: .success, colorStyle: colorStyle, colorTextButton: colorTextButton, circleIconImage: circleIconImage, animationStyle: animationStyle)
  623 + open func showSuccess(_ title: String, subTitle: String, closeButtonTitle:String?=nil, timeout:SCLTimeoutConfiguration?=nil, colorStyle: UInt=SCLAlertViewStyle.success.defaultColorInt, colorTextButton: UInt=0xFFFFFF, circleIconImage: UIImage? = nil, animationStyle: SCLAnimationStyle = .topToBottom) -> SCLAlertViewResponder {
  624 + return showTitle(title, subTitle: subTitle, timeout: timeout, completeText:closeButtonTitle, style: .success, colorStyle: colorStyle, colorTextButton: colorTextButton, circleIconImage: circleIconImage, animationStyle: animationStyle)
570 625 }
571   -
  626 +
572 627 // showError(view, title, subTitle)
573 628 @discardableResult
574   - open func showError(_ title: String, subTitle: String, closeButtonTitle:String?=nil, duration:TimeInterval=0.0, colorStyle: UInt=SCLAlertViewStyle.error.defaultColorInt, colorTextButton: UInt=0xFFFFFF, circleIconImage: UIImage? = nil, animationStyle: SCLAnimationStyle = .topToBottom) -> SCLAlertViewResponder {
575   - return showTitle(title, subTitle: subTitle, duration: duration, completeText:closeButtonTitle, style: .error, colorStyle: colorStyle, colorTextButton: colorTextButton, circleIconImage: circleIconImage, animationStyle: animationStyle)
  629 + open func showError(_ title: String, subTitle: String, closeButtonTitle:String?=nil, timeout:SCLTimeoutConfiguration?=nil, colorStyle: UInt=SCLAlertViewStyle.error.defaultColorInt, colorTextButton: UInt=0xFFFFFF, circleIconImage: UIImage? = nil, animationStyle: SCLAnimationStyle = .topToBottom) -> SCLAlertViewResponder {
  630 + return showTitle(title, subTitle: subTitle, timeout: timeout, completeText:closeButtonTitle, style: .error, colorStyle: colorStyle, colorTextButton: colorTextButton, circleIconImage: circleIconImage, animationStyle: animationStyle)
576 631 }
577   -
  632 +
578 633 // showNotice(view, title, subTitle)
579 634 @discardableResult
580   - open func showNotice(_ title: String, subTitle: String, closeButtonTitle:String?=nil, duration:TimeInterval=0.0, colorStyle: UInt=SCLAlertViewStyle.notice.defaultColorInt, colorTextButton: UInt=0xFFFFFF, circleIconImage: UIImage? = nil, animationStyle: SCLAnimationStyle = .topToBottom) -> SCLAlertViewResponder {
581   - return showTitle(title, subTitle: subTitle, duration: duration, completeText:closeButtonTitle, style: .notice, colorStyle: colorStyle, colorTextButton: colorTextButton, circleIconImage: circleIconImage, animationStyle: animationStyle)
  635 + open func showNotice(_ title: String, subTitle: String, closeButtonTitle:String?=nil, timeout:SCLTimeoutConfiguration?=nil, colorStyle: UInt=SCLAlertViewStyle.notice.defaultColorInt, colorTextButton: UInt=0xFFFFFF, circleIconImage: UIImage? = nil, animationStyle: SCLAnimationStyle = .topToBottom) -> SCLAlertViewResponder {
  636 + return showTitle(title, subTitle: subTitle, timeout: timeout, completeText:closeButtonTitle, style: .notice, colorStyle: colorStyle, colorTextButton: colorTextButton, circleIconImage: circleIconImage, animationStyle: animationStyle)
582 637 }
583   -
  638 +
584 639 // showWarning(view, title, subTitle)
585 640 @discardableResult
586   - open func showWarning(_ title: String, subTitle: String, closeButtonTitle:String?=nil, duration:TimeInterval=0.0, colorStyle: UInt=SCLAlertViewStyle.warning.defaultColorInt, colorTextButton: UInt=0x000000, circleIconImage: UIImage? = nil, animationStyle: SCLAnimationStyle = .topToBottom) -> SCLAlertViewResponder {
587   - return showTitle(title, subTitle: subTitle, duration: duration, completeText:closeButtonTitle, style: .warning, colorStyle: colorStyle, colorTextButton: colorTextButton, circleIconImage: circleIconImage, animationStyle: animationStyle)
  641 + open func showWarning(_ title: String, subTitle: String, closeButtonTitle:String?=nil, timeout:SCLTimeoutConfiguration?=nil, colorStyle: UInt=SCLAlertViewStyle.warning.defaultColorInt, colorTextButton: UInt=0x000000, circleIconImage: UIImage? = nil, animationStyle: SCLAnimationStyle = .topToBottom) -> SCLAlertViewResponder {
  642 + return showTitle(title, subTitle: subTitle, timeout: timeout, completeText:closeButtonTitle, style: .warning, colorStyle: colorStyle, colorTextButton: colorTextButton, circleIconImage: circleIconImage, animationStyle: animationStyle)
588 643 }
589   -
  644 +
590 645 // showInfo(view, title, subTitle)
591 646 @discardableResult
592   - open func showInfo(_ title: String, subTitle: String, closeButtonTitle:String?=nil, duration:TimeInterval=0.0, colorStyle: UInt=SCLAlertViewStyle.info.defaultColorInt, colorTextButton: UInt=0xFFFFFF, circleIconImage: UIImage? = nil, animationStyle: SCLAnimationStyle = .topToBottom) -> SCLAlertViewResponder {
593   - return showTitle(title, subTitle: subTitle, duration: duration, completeText:closeButtonTitle, style: .info, colorStyle: colorStyle, colorTextButton: colorTextButton, circleIconImage: circleIconImage, animationStyle: animationStyle)
  647 + open func showInfo(_ title: String, subTitle: String, closeButtonTitle:String?=nil, timeout:SCLTimeoutConfiguration?=nil, colorStyle: UInt=SCLAlertViewStyle.info.defaultColorInt, colorTextButton: UInt=0xFFFFFF, circleIconImage: UIImage? = nil, animationStyle: SCLAnimationStyle = .topToBottom) -> SCLAlertViewResponder {
  648 + return showTitle(title, subTitle: subTitle, timeout: timeout, completeText:closeButtonTitle, style: .info, colorStyle: colorStyle, colorTextButton: colorTextButton, circleIconImage: circleIconImage, animationStyle: animationStyle)
594 649 }
595   -
  650 +
596 651 // showWait(view, title, subTitle)
597 652 @discardableResult
598   - open func showWait(_ title: String, subTitle: String, closeButtonTitle:String?=nil, duration:TimeInterval=0.0, colorStyle: UInt?=SCLAlertViewStyle.wait.defaultColorInt, colorTextButton: UInt=0xFFFFFF, circleIconImage: UIImage? = nil, animationStyle: SCLAnimationStyle = .topToBottom) -> SCLAlertViewResponder {
599   - return showTitle(title, subTitle: subTitle, duration: duration, completeText:closeButtonTitle, style: .wait, colorStyle: colorStyle, colorTextButton: colorTextButton, circleIconImage: circleIconImage, animationStyle: animationStyle)
  653 + open func showWait(_ title: String, subTitle: String, closeButtonTitle:String?=nil, timeout:SCLTimeoutConfiguration?=nil, colorStyle: UInt?=SCLAlertViewStyle.wait.defaultColorInt, colorTextButton: UInt=0xFFFFFF, circleIconImage: UIImage? = nil, animationStyle: SCLAnimationStyle = .topToBottom) -> SCLAlertViewResponder {
  654 + return showTitle(title, subTitle: subTitle, timeout: timeout, completeText:closeButtonTitle, style: .wait, colorStyle: colorStyle, colorTextButton: colorTextButton, circleIconImage: circleIconImage, animationStyle: animationStyle)
600 655 }
601   -
  656 +
602 657 @discardableResult
603   - open func showEdit(_ title: String, subTitle: String, closeButtonTitle:String?=nil, duration:TimeInterval=0.0, colorStyle: UInt=SCLAlertViewStyle.edit.defaultColorInt, colorTextButton: UInt=0xFFFFFF, circleIconImage: UIImage? = nil, animationStyle: SCLAnimationStyle = .topToBottom) -> SCLAlertViewResponder {
604   - return showTitle(title, subTitle: subTitle, duration: duration, completeText:closeButtonTitle, style: .edit, colorStyle: colorStyle, colorTextButton: colorTextButton, circleIconImage: circleIconImage, animationStyle: animationStyle)
  658 + open func showEdit(_ title: String, subTitle: String, closeButtonTitle:String?=nil, timeout:SCLTimeoutConfiguration?=nil, colorStyle: UInt=SCLAlertViewStyle.edit.defaultColorInt, colorTextButton: UInt=0xFFFFFF, circleIconImage: UIImage? = nil, animationStyle: SCLAnimationStyle = .topToBottom) -> SCLAlertViewResponder {
  659 + return showTitle(title, subTitle: subTitle, timeout: timeout, completeText:closeButtonTitle, style: .edit, colorStyle: colorStyle, colorTextButton: colorTextButton, circleIconImage: circleIconImage, animationStyle: animationStyle)
605 660 }
606   -
  661 +
607 662 // showTitle(view, title, subTitle, style)
608 663 @discardableResult
609   - open func showTitle(_ title: String, subTitle: String, style: SCLAlertViewStyle, closeButtonTitle:String?=nil, duration:TimeInterval=0.0, colorStyle: UInt?=0x000000, colorTextButton: UInt=0xFFFFFF, circleIconImage: UIImage? = nil, animationStyle: SCLAnimationStyle = .topToBottom) -> SCLAlertViewResponder {
610   -
611   - return showTitle(title, subTitle: subTitle, duration:duration, completeText:closeButtonTitle, style: style, colorStyle: colorStyle, colorTextButton: colorTextButton, circleIconImage: circleIconImage, animationStyle: animationStyle)
  664 + open func showTitle(_ title: String, subTitle: String, style: SCLAlertViewStyle, closeButtonTitle:String?=nil, timeout:SCLTimeoutConfiguration?=nil, colorStyle: UInt?=0x000000, colorTextButton: UInt=0xFFFFFF, circleIconImage: UIImage? = nil, animationStyle: SCLAnimationStyle = .topToBottom) -> SCLAlertViewResponder {
  665 +
  666 + return showTitle(title, subTitle: subTitle, timeout:timeout, completeText:closeButtonTitle, style: style, colorStyle: colorStyle, colorTextButton: colorTextButton, circleIconImage: circleIconImage, animationStyle: animationStyle)
612 667 }
613   -
614   - // showTitle(view, title, subTitle, duration, style)
  668 +
  669 + // showTitle(view, title, subTitle, timeout, style)
615 670 @discardableResult
616   - open func showTitle(_ title: String, subTitle: String, duration: TimeInterval?, completeText: String?, style: SCLAlertViewStyle, colorStyle: UInt?=0x000000, colorTextButton: UInt?=0xFFFFFF, circleIconImage: UIImage? = nil, animationStyle: SCLAnimationStyle = .topToBottom) -> SCLAlertViewResponder {
  671 + open func showTitle(_ title: String, subTitle: String, timeout: SCLTimeoutConfiguration?, completeText: String?, style: SCLAlertViewStyle, colorStyle: UInt?=0x000000, colorTextButton: UInt?=0xFFFFFF, circleIconImage: UIImage? = nil, animationStyle: SCLAnimationStyle = .topToBottom) -> SCLAlertViewResponder {
617 672 selfReference = self
618 673 view.alpha = 0
  674 + view.tag = uniqueTag
  675 + view.accessibilityIdentifier = uniqueAccessibilityIdentifier
619 676 let rv = UIApplication.shared.keyWindow! as UIWindow
620 677 rv.addSubview(view)
621 678 view.frame = rv.bounds
622 679 baseView.frame = rv.bounds
623   -
  680 +
624 681 // Alert colour/icon
625 682 viewColor = UIColor()
626 683 var iconImage: UIImage?
627 684  
628 685  
629 686  
630 687  
631 688  
632 689  
633 690  
634 691  
635 692  
636 693  
637 694  
638 695  
639 696  
640 697  
641 698  
... ... @@ -629,38 +686,43 @@
629 686 // Icon style
630 687 switch style {
631 688 case .success:
632   -
  689 +
633 690 iconImage = checkCircleIconImage(circleIconImage, defaultImage: SCLAlertViewStyleKit.imageOfCheckmark)
634   -
  691 +
635 692 case .error:
636   -
  693 +
637 694 iconImage = checkCircleIconImage(circleIconImage, defaultImage: SCLAlertViewStyleKit.imageOfCross)
638   -
  695 +
639 696 case .notice:
640   -
  697 +
641 698 iconImage = checkCircleIconImage(circleIconImage, defaultImage:SCLAlertViewStyleKit.imageOfNotice)
642   -
  699 +
643 700 case .warning:
644   -
  701 +
645 702 iconImage = checkCircleIconImage(circleIconImage, defaultImage:SCLAlertViewStyleKit.imageOfWarning)
646   -
  703 +
647 704 case .info:
648   -
  705 +
649 706 iconImage = checkCircleIconImage(circleIconImage, defaultImage:SCLAlertViewStyleKit.imageOfInfo)
650   -
  707 +
651 708 case .edit:
652   -
  709 +
653 710 iconImage = checkCircleIconImage(circleIconImage, defaultImage:SCLAlertViewStyleKit.imageOfEdit)
654   -
  711 +
655 712 case .wait:
656 713 iconImage = nil
  714 +
  715 + case .question:
  716 + iconImage = checkCircleIconImage(circleIconImage, defaultImage:SCLAlertViewStyleKit.imageOfQuestion)
657 717 }
658   -
  718 +
659 719 // Title
660 720 if !title.isEmpty {
661 721 self.labelTitle.text = title
  722 + let actualHeight = title.heightWithConstrainedWidth(width: appearance.kWindowWidth - 24, font: self.labelTitle.font)
  723 + self.labelTitle.frame = CGRect(x:12, y:appearance.kTitleTop, width: appearance.kWindowWidth - 24, height:actualHeight)
662 724 }
663   -
  725 +
664 726 // Subtitle
665 727 if !subTitle.isEmpty {
666 728 viewText.text = subTitle
667 729  
668 730  
... ... @@ -675,16 +737,16 @@
675 737 appearance.setkTextHeight(ht)
676 738 }
677 739 }
678   -
  740 +
679 741 // Done button
680 742 if appearance.showCloseButton {
681 743 _ = addButton(completeText ?? "Done", target:self, selector:#selector(SCLAlertView.hideView))
682 744 }
683   -
  745 +
684 746 //hidden/show circular view based on the ui option
685 747 circleView.isHidden = !appearance.showCircularIcon
686 748 circleBG.isHidden = !appearance.showCircularIcon
687   -
  749 +
688 750 // Alert view colour and images
689 751 circleView.backgroundColor = viewColor
690 752 // Spinner / icon
691 753  
692 754  
... ... @@ -707,15 +769,15 @@
707 769 circleIconView!.frame = CGRect( x: x, y: x, width: appearance.kCircleIconHeight, height: appearance.kCircleIconHeight)
708 770 circleIconView?.layer.cornerRadius = circleIconView!.bounds.height / 2
709 771 circleIconView?.layer.masksToBounds = true
710   -
  772 +
711 773 for txt in inputs {
712 774 txt.layer.borderColor = viewColor.cgColor
713 775 }
714   -
  776 +
715 777 for txt in input {
716 778 txt.layer.borderColor = viewColor.cgColor
717 779 }
718   -
  780 +
719 781 for btn in buttons {
720 782 if let customBackgroundColor = btn.customBackgroundColor {
721 783 // Custom BackgroundColor set
... ... @@ -724,7 +786,7 @@
724 786 // Use default BackgroundColor derived from AlertStyle
725 787 btn.backgroundColor = viewColor
726 788 }
727   -
  789 +
728 790 if let customTextColor = btn.customTextColor {
729 791 // Custom TextColor set
730 792 btn.setTitleColor(customTextColor, for:UIControlState())
731 793  
732 794  
733 795  
734 796  
735 797  
736 798  
737 799  
738 800  
739 801  
740 802  
741 803  
742 804  
743 805  
744 806  
745 807  
746 808  
747 809  
... ... @@ -733,101 +795,145 @@
733 795 btn.setTitleColor(UIColorFromRGB(colorTextButton ?? 0xFFFFFF), for:UIControlState())
734 796 }
735 797 }
736   -
737   - // Adding duration
738   - if duration > 0 {
739   - self.duration = duration
740   - durationTimer?.invalidate()
741   - durationTimer = Timer.scheduledTimer(timeInterval: self.duration, target: self, selector: #selector(SCLAlertView.hideView), userInfo: nil, repeats: false)
742   - durationStatusTimer?.invalidate()
743   - durationStatusTimer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(SCLAlertView.updateDurationStatus), userInfo: nil, repeats: true)
  798 +
  799 + // Adding timeout
  800 + if let timeout = timeout {
  801 + self.timeout = timeout
  802 + timeoutTimer?.invalidate()
  803 + timeoutTimer = Timer.scheduledTimer(timeInterval: timeout.value, target: self, selector: #selector(SCLAlertView.hideViewTimeout), userInfo: nil, repeats: false)
  804 + showTimeoutTimer?.invalidate()
  805 + showTimeoutTimer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(SCLAlertView.updateShowTimeout), userInfo: nil, repeats: true)
744 806 }
745   -
  807 +
746 808 // Animate in the alert view
747 809 self.showAnimation(animationStyle)
748   -
  810 +
749 811 // Chainable objects
750 812 return SCLAlertViewResponder(alertview: self)
751 813 }
752   -
  814 +
753 815 // Show animation in the alert view
754 816 fileprivate func showAnimation(_ animationStyle: SCLAnimationStyle = .topToBottom, animationStartOffset: CGFloat = -400.0, boundingAnimationOffset: CGFloat = 15.0, animationDuration: TimeInterval = 0.2) {
755   -
  817 +
756 818 let rv = UIApplication.shared.keyWindow! as UIWindow
757 819 var animationStartOrigin = self.baseView.frame.origin
758 820 var animationCenter : CGPoint = rv.center
759   -
  821 +
760 822 switch animationStyle {
761 823  
762 824 case .noAnimation:
763 825 self.view.alpha = 1.0
764 826 return;
765   -
  827 +
766 828 case .topToBottom:
767 829 animationStartOrigin = CGPoint(x: animationStartOrigin.x, y: self.baseView.frame.origin.y + animationStartOffset)
768 830 animationCenter = CGPoint(x: animationCenter.x, y: animationCenter.y + boundingAnimationOffset)
769   -
  831 +
770 832 case .bottomToTop:
771 833 animationStartOrigin = CGPoint(x: animationStartOrigin.x, y: self.baseView.frame.origin.y - animationStartOffset)
772 834 animationCenter = CGPoint(x: animationCenter.x, y: animationCenter.y - boundingAnimationOffset)
773   -
  835 +
774 836 case .leftToRight:
775 837 animationStartOrigin = CGPoint(x: self.baseView.frame.origin.x + animationStartOffset, y: animationStartOrigin.y)
776 838 animationCenter = CGPoint(x: animationCenter.x + boundingAnimationOffset, y: animationCenter.y)
777   -
  839 +
778 840 case .rightToLeft:
779 841 animationStartOrigin = CGPoint(x: self.baseView.frame.origin.x - animationStartOffset, y: animationStartOrigin.y)
780 842 animationCenter = CGPoint(x: animationCenter.x - boundingAnimationOffset, y: animationCenter.y)
781 843 }
782 844  
783 845 self.baseView.frame.origin = animationStartOrigin
784   - UIView.animate(withDuration: animationDuration, animations: {
785   - self.view.alpha = 1.0
786   - self.baseView.center = animationCenter
  846 +
  847 + if self.appearance.dynamicAnimatorActive {
  848 + UIView.animate(withDuration: animationDuration, animations: {
  849 + self.view.alpha = 1.0
  850 + })
  851 + self.animate(item: self.baseView, center: rv.center)
  852 + } else {
  853 + UIView.animate(withDuration: animationDuration, animations: {
  854 + self.view.alpha = 1.0
  855 + self.baseView.center = animationCenter
787 856 }, completion: { finished in
788 857 UIView.animate(withDuration: animationDuration, animations: {
789 858 self.view.alpha = 1.0
790 859 self.baseView.center = rv.center
791 860 })
792   - })
  861 + })
  862 + }
793 863 }
794   -
795   - open func updateDurationStatus() {
796   - duration = duration.advanced(by: -1)
797   - for btn in buttons.filter({$0.showDurationStatus}) {
798   - let txt = "\(btn.initialTitle) (\(duration))"
  864 +
  865 + // DynamicAnimator function
  866 + var animator : UIDynamicAnimator?
  867 + var snapBehavior : UISnapBehavior?
  868 +
  869 + fileprivate func animate(item : UIView , center: CGPoint) {
  870 +
  871 + if let snapBehavior = self.snapBehavior {
  872 + self.animator?.removeBehavior(snapBehavior)
  873 + }
  874 +
  875 + self.animator = UIDynamicAnimator.init(referenceView: self.view)
  876 + let tempSnapBehavior = UISnapBehavior.init(item: item, snapTo: center)
  877 + self.animator?.addBehavior(tempSnapBehavior)
  878 + self.snapBehavior? = tempSnapBehavior
  879 + }
  880 +
  881 + //
  882 + open func updateShowTimeout() {
  883 +
  884 + guard let timeout = self.timeout else {
  885 + return
  886 + }
  887 +
  888 + self.timeout?.value = timeout.value.advanced(by: -1)
  889 +
  890 + for btn in buttons {
  891 + guard let showTimeout = btn.showTimeout else {
  892 + continue
  893 + }
  894 +
  895 + let timeoutStr: String = showTimeout.prefix + String(Int(timeout.value)) + showTimeout.suffix
  896 + let txt = String(btn.initialTitle) + " " + timeoutStr
799 897 btn.setTitle(txt, for: UIControlState())
  898 +
800 899 }
  900 +
801 901 }
802   -
  902 +
803 903 // Close SCLAlertView
804 904 open func hideView() {
805 905 UIView.animate(withDuration: 0.2, animations: {
806 906 self.view.alpha = 0
807   - }, completion: { finished in
808   -
809   - //Stop durationTimer so alertView does not attempt to hide itself and fire it's dimiss block a second time when close button is tapped
810   - self.durationTimer?.invalidate()
811   - // Stop StatusTimer
812   - self.durationStatusTimer?.invalidate()
813   -
814   - if(self.dismissBlock != nil) {
815   - // Call completion handler when the alert is dismissed
816   - self.dismissBlock!()
817   - }
818   -
819   - // This is necessary for SCLAlertView to be de-initialized, preventing a strong reference cycle with the viewcontroller calling SCLAlertView.
820   - for button in self.buttons {
821   - button.action = nil
822   - button.target = nil
823   - button.selector = nil
824   - }
825   -
826   - self.view.removeFromSuperview()
827   - self.selfReference = nil
  907 + }, completion: { finished in
  908 +
  909 + // Stop timeoutTimer so alertView does not attempt to hide itself and fire it's dimiss block a second time when close button is tapped
  910 + self.timeoutTimer?.invalidate()
  911 +
  912 + // Stop showTimeoutTimer
  913 + self.showTimeoutTimer?.invalidate()
  914 +
  915 + if let dismissBlock = self.dismissBlock {
  916 + // Call completion handler when the alert is dismissed
  917 + dismissBlock()
  918 + }
  919 +
  920 + // This is necessary for SCLAlertView to be de-initialized, preventing a strong reference cycle with the viewcontroller calling SCLAlertView.
  921 + for button in self.buttons {
  922 + button.action = nil
  923 + button.target = nil
  924 + button.selector = nil
  925 + }
  926 +
  927 + self.view.removeFromSuperview()
  928 + self.selfReference = nil
828 929 })
829 930 }
830   -
  931 +
  932 + open func hideViewTimeout() {
  933 + self.timeout?.action()
  934 + self.hideView()
  935 + }
  936 +
831 937 func checkCircleIconImage(_ circleIconImage: UIImage?, defaultImage: UIImage) -> UIImage {
832 938 if let image = circleIconImage {
833 939 return image
834 940  
... ... @@ -835,15 +941,27 @@
835 941 return defaultImage
836 942 }
837 943 }
  944 +
  945 + //Return true if a SCLAlertView is already being shown, false otherwise
  946 + open func isShowing() -> Bool {
  947 + if let subviews = UIApplication.shared.keyWindow?.subviews {
  948 + for view in subviews {
  949 + if view.tag == uniqueTag && view.accessibilityIdentifier == uniqueAccessibilityIdentifier {
  950 + return true
  951 + }
  952 + }
  953 + }
  954 + return false
  955 + }
838 956 }
839 957  
840 958 // Helper function to convert from RGB to UIColor
841 959 func UIColorFromRGB(_ rgbValue: UInt) -> UIColor {
842 960 return UIColor(
843   - red: CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0,
844   - green: CGFloat((rgbValue & 0x00FF00) >> 8) / 255.0,
845   - blue: CGFloat(rgbValue & 0x0000FF) / 255.0,
846   - alpha: CGFloat(1.0)
  961 + red: CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0,
  962 + green: CGFloat((rgbValue & 0x00FF00) >> 8) / 255.0,
  963 + blue: CGFloat(rgbValue & 0x0000FF) / 255.0,
  964 + alpha: CGFloat(1.0)
847 965 )
848 966 }
849 967  
... ... @@ -853,7 +971,7 @@
853 971 // ------------------------------------
854 972  
855 973 class SCLAlertViewStyleKit : NSObject {
856   -
  974 +
857 975 // Cache
858 976 struct Cache {
859 977 static var imageOfCheckmark: UIImage?
860 978  
861 979  
... ... @@ -868,13 +986,15 @@
868 986 static var infoTargets: [AnyObject]?
869 987 static var imageOfEdit: UIImage?
870 988 static var editTargets: [AnyObject]?
  989 + static var imageOfQuestion: UIImage?
  990 + static var questionTargets: [AnyObject]?
871 991 }
872   -
  992 +
873 993 // Initialization
874 994 /// swift 1.2 abolish func load
875 995 // override class func load() {
876 996 // }
877   -
  997 +
878 998 // Drawing Methods
879 999 class func drawCheckmark() {
880 1000 // Checkmark Shape Drawing
881 1001  
... ... @@ -892,11 +1012,11 @@
892 1012 checkmarkShapePath.addCurve(to: CGPoint(x: 73.25, y: 14.05), controlPoint1: CGPoint(x: 75.52, y: 20.75), controlPoint2: CGPoint(x: 75.7, y: 16.65))
893 1013 checkmarkShapePath.close()
894 1014 checkmarkShapePath.miterLimit = 4;
895   -
  1015 +
896 1016 UIColor.white.setFill()
897 1017 checkmarkShapePath.fill()
898 1018 }
899   -
  1019 +
900 1020 class func drawCross() {
901 1021 // Cross Shape Drawing
902 1022 let crossShapePath = UIBezierPath()
... ... @@ -910,7 +1030,7 @@
910 1030 crossShapePath.lineWidth = 14
911 1031 crossShapePath.stroke()
912 1032 }
913   -
  1033 +
914 1034 class func drawNotice() {
915 1035 // Notice Shape Drawing
916 1036 let noticeShapePath = UIBezierPath()
917 1037  
918 1038  
... ... @@ -943,15 +1063,15 @@
943 1063 noticeShapePath.addCurve(to: CGPoint(x: 72, y: 48.54), controlPoint1: CGPoint(x: 71.81, y: 51.29), controlPoint2: CGPoint(x: 72, y: 49.72))
944 1064 noticeShapePath.close()
945 1065 noticeShapePath.miterLimit = 4;
946   -
  1066 +
947 1067 UIColor.white.setFill()
948 1068 noticeShapePath.fill()
949 1069 }
950   -
  1070 +
951 1071 class func drawWarning() {
952 1072 // Color Declarations
953 1073 let greyColor = UIColor(red: 0.236, green: 0.236, blue: 0.236, alpha: 1.000)
954   -
  1074 +
955 1075 // Warning Group
956 1076 // Warning Circle Drawing
957 1077 let warningCirclePath = UIBezierPath()
958 1078  
... ... @@ -966,11 +1086,11 @@
966 1086 warningCirclePath.addCurve(to: CGPoint(x: 40.94, y: 63.39), controlPoint1: CGPoint(x: 44.53, y: 64.18), controlPoint2: CGPoint(x: 42.83, y: 63.39))
967 1087 warningCirclePath.close()
968 1088 warningCirclePath.miterLimit = 4;
969   -
  1089 +
970 1090 greyColor.setFill()
971 1091 warningCirclePath.fill()
972   -
973   -
  1092 +
  1093 +
974 1094 // Warning Shape Drawing
975 1095 let warningShapePath = UIBezierPath()
976 1096 warningShapePath.move(to: CGPoint(x: 46.23, y: 4.26))
977 1097  
978 1098  
... ... @@ -986,15 +1106,15 @@
986 1106 warningShapePath.addCurve(to: CGPoint(x: 46.23, y: 4.26), controlPoint1: CGPoint(x: 48.5, y: 7.01), controlPoint2: CGPoint(x: 47.74, y: 5.44))
987 1107 warningShapePath.close()
988 1108 warningShapePath.miterLimit = 4;
989   -
  1109 +
990 1110 greyColor.setFill()
991 1111 warningShapePath.fill()
992 1112 }
993   -
  1113 +
994 1114 class func drawInfo() {
995 1115 // Color Declarations
996 1116 let color0 = UIColor(red: 1.000, green: 1.000, blue: 1.000, alpha: 1.000)
997   -
  1117 +
998 1118 // Info Shape Drawing
999 1119 let infoShapePath = UIBezierPath()
1000 1120 infoShapePath.move(to: CGPoint(x: 45.66, y: 15.96))
1001 1121  
... ... @@ -1016,11 +1136,11 @@
1016 1136 color0.setFill()
1017 1137 infoShapePath.fill()
1018 1138 }
1019   -
  1139 +
1020 1140 class func drawEdit() {
1021 1141 // Color Declarations
1022 1142 let color = UIColor(red:1.0, green:1.0, blue:1.0, alpha:1.0)
1023   -
  1143 +
1024 1144 // Edit shape Drawing
1025 1145 let editPathPath = UIBezierPath()
1026 1146 editPathPath.move(to: CGPoint(x: 71, y: 2.7))
... ... @@ -1063,7 +1183,36 @@
1063 1183 color.setFill()
1064 1184 editPathPath.fill()
1065 1185 }
1066   -
  1186 +
  1187 + class func drawQuestion() {
  1188 + // Color Declarations
  1189 + let color = UIColor(red: CGFloat(1.0), green: CGFloat(1.0), blue: CGFloat(1.0), alpha: CGFloat(1.0))
  1190 + // Questionmark Shape Drawing
  1191 + let questionShapePath = UIBezierPath()
  1192 + questionShapePath.move(to: CGPoint(x: CGFloat(33.75), y: CGFloat(54.1)))
  1193 + questionShapePath.addLine(to: CGPoint(x: CGFloat(44.15), y: CGFloat(54.1)))
  1194 + questionShapePath.addLine(to: CGPoint(x: CGFloat(44.15), y: CGFloat(47.5)))
  1195 + questionShapePath.addCurve(to: CGPoint(x: CGFloat(51.85), y: CGFloat(37.2)), controlPoint1: CGPoint(x: CGFloat(44.15), y: CGFloat(42.9)), controlPoint2: CGPoint(x: CGFloat(46.75), y: CGFloat(41.2)))
  1196 + questionShapePath.addCurve(to: CGPoint(x: CGFloat(61.95), y: CGFloat(19.9)), controlPoint1: CGPoint(x: CGFloat(59.05), y: CGFloat(31.6)), controlPoint2: CGPoint(x: CGFloat(61.95), y: CGFloat(28.5)))
  1197 + questionShapePath.addCurve(to: CGPoint(x: CGFloat(41.45), y: CGFloat(2.8)), controlPoint1: CGPoint(x: CGFloat(61.95), y: CGFloat(7.6)), controlPoint2: CGPoint(x: CGFloat(52.85), y: CGFloat(2.8)))
  1198 + questionShapePath.addCurve(to: CGPoint(x: CGFloat(25.05), y: CGFloat(5.8)), controlPoint1: CGPoint(x: CGFloat(34.75), y: CGFloat(2.8)), controlPoint2: CGPoint(x: CGFloat(29.65), y: CGFloat(3.8)))
  1199 + questionShapePath.addLine(to: CGPoint(x: CGFloat(25.05), y: CGFloat(14.4)))
  1200 + questionShapePath.addCurve(to: CGPoint(x: CGFloat(38.15), y: CGFloat(12.3)), controlPoint1: CGPoint(x: CGFloat(29.15), y: CGFloat(13.2)), controlPoint2: CGPoint(x: CGFloat(32.35), y: CGFloat(12.3)))
  1201 + questionShapePath.addCurve(to: CGPoint(x: CGFloat(49.65), y: CGFloat(20.8)), controlPoint1: CGPoint(x: CGFloat(45.65), y: CGFloat(12.3)), controlPoint2: CGPoint(x: CGFloat(49.65), y: CGFloat(14.4)))
  1202 + questionShapePath.addCurve(to: CGPoint(x: CGFloat(43.65), y: CGFloat(31.7)), controlPoint1: CGPoint(x: CGFloat(49.65), y: CGFloat(26)), controlPoint2: CGPoint(x: CGFloat(47.95), y: CGFloat(28.4)))
  1203 + questionShapePath.addCurve(to: CGPoint(x: CGFloat(33.75), y: CGFloat(46.6)), controlPoint1: CGPoint(x: CGFloat(37.15), y: CGFloat(36.9)), controlPoint2: CGPoint(x: CGFloat(33.75), y: CGFloat(39.7)))
  1204 + questionShapePath.addLine(to: CGPoint(x: CGFloat(33.75), y: CGFloat(54.1)))
  1205 + questionShapePath.close()
  1206 + questionShapePath.move(to: CGPoint(x: CGFloat(33.15), y: CGFloat(75.4)))
  1207 + questionShapePath.addLine(to: CGPoint(x: CGFloat(45.35), y: CGFloat(75.4)))
  1208 + questionShapePath.addLine(to: CGPoint(x: CGFloat(45.35), y: CGFloat(63.7)))
  1209 + questionShapePath.addLine(to: CGPoint(x: CGFloat(33.15), y: CGFloat(63.7)))
  1210 + questionShapePath.addLine(to: CGPoint(x: CGFloat(33.15), y: CGFloat(75.4)))
  1211 + questionShapePath.close()
  1212 + color.setFill()
  1213 + questionShapePath.fill()
  1214 + }
  1215 +
1067 1216 // Generated Images
1068 1217 class var imageOfCheckmark: UIImage {
1069 1218 if (Cache.imageOfCheckmark != nil) {
... ... @@ -1075,7 +1224,7 @@
1075 1224 UIGraphicsEndImageContext()
1076 1225 return Cache.imageOfCheckmark!
1077 1226 }
1078   -
  1227 +
1079 1228 class var imageOfCross: UIImage {
1080 1229 if (Cache.imageOfCross != nil) {
1081 1230 return Cache.imageOfCross!
... ... @@ -1086,7 +1235,7 @@
1086 1235 UIGraphicsEndImageContext()
1087 1236 return Cache.imageOfCross!
1088 1237 }
1089   -
  1238 +
1090 1239 class var imageOfNotice: UIImage {
1091 1240 if (Cache.imageOfNotice != nil) {
1092 1241 return Cache.imageOfNotice!
... ... @@ -1097,7 +1246,7 @@
1097 1246 UIGraphicsEndImageContext()
1098 1247 return Cache.imageOfNotice!
1099 1248 }
1100   -
  1249 +
1101 1250 class var imageOfWarning: UIImage {
1102 1251 if (Cache.imageOfWarning != nil) {
1103 1252 return Cache.imageOfWarning!
... ... @@ -1108,7 +1257,7 @@
1108 1257 UIGraphicsEndImageContext()
1109 1258 return Cache.imageOfWarning!
1110 1259 }
1111   -
  1260 +
1112 1261 class var imageOfInfo: UIImage {
1113 1262 if (Cache.imageOfInfo != nil) {
1114 1263 return Cache.imageOfInfo!
... ... @@ -1119,7 +1268,7 @@
1119 1268 UIGraphicsEndImageContext()
1120 1269 return Cache.imageOfInfo!
1121 1270 }
1122   -
  1271 +
1123 1272 class var imageOfEdit: UIImage {
1124 1273 if (Cache.imageOfEdit != nil) {
1125 1274 return Cache.imageOfEdit!
... ... @@ -1129,6 +1278,17 @@
1129 1278 Cache.imageOfEdit = UIGraphicsGetImageFromCurrentImageContext()
1130 1279 UIGraphicsEndImageContext()
1131 1280 return Cache.imageOfEdit!
  1281 + }
  1282 +
  1283 + class var imageOfQuestion: UIImage {
  1284 + if (Cache.imageOfQuestion != nil) {
  1285 + return Cache.imageOfQuestion!
  1286 + }
  1287 + UIGraphicsBeginImageContextWithOptions(CGSize(width: 80, height: 80), false, 0)
  1288 + SCLAlertViewStyleKit.drawQuestion()
  1289 + Cache.imageOfQuestion = UIGraphicsGetImageFromCurrentImageContext()
  1290 + UIGraphicsEndImageContext()
  1291 + return Cache.imageOfQuestion!
1132 1292 }
1133 1293 }
GeneralUtils/GeneralUtils/libs/SCLAlertView/SCLExtensions.swift
... ... @@ -9,34 +9,46 @@
9 9 import UIKit
10 10  
11 11 extension Int {
12   -
  12 +
13 13 func toUIColor() -> UIColor {
14 14 return UIColor(
15   - red: CGFloat((self & 0xFF0000) >> 16) / 255.0,
16   - green: CGFloat((self & 0x00FF00) >> 8) / 255.0,
17   - blue: CGFloat(self & 0x0000FF) / 255.0,
18   - alpha: CGFloat(1.0)
  15 + red: CGFloat((self & 0xFF0000) >> 16) / 255.0,
  16 + green: CGFloat((self & 0x00FF00) >> 8) / 255.0,
  17 + blue: CGFloat(self & 0x0000FF) / 255.0,
  18 + alpha: CGFloat(1.0)
19 19 )
20 20 }
21   -
  21 +
22 22 func toCGColor() -> CGColor {
23 23 return self.toUIColor().cgColor
24 24 }
25 25 }
26 26  
27 27 extension UInt {
28   -
  28 +
29 29 func toUIColor() -> UIColor {
30 30 return UIColor(
31   - red: CGFloat((self & 0xFF0000) >> 16) / 255.0,
32   - green: CGFloat((self & 0x00FF00) >> 8) / 255.0,
33   - blue: CGFloat(self & 0x0000FF) / 255.0,
34   - alpha: CGFloat(1.0)
  31 + red: CGFloat((self & 0xFF0000) >> 16) / 255.0,
  32 + green: CGFloat((self & 0x00FF00) >> 8) / 255.0,
  33 + blue: CGFloat(self & 0x0000FF) / 255.0,
  34 + alpha: CGFloat(1.0)
35 35 )
36 36 }
37   -
  37 +
38 38 func toCGColor() -> CGColor {
39 39 return self.toUIColor().cgColor
40 40 }
  41 +}
  42 +
  43 +extension String {
  44 +
  45 + func heightWithConstrainedWidth(width: CGFloat, font: UIFont) -> CGFloat {
  46 + let constraintRect = CGSize(width: width, height: CGFloat.greatestFiniteMagnitude)
  47 +
  48 + let boundingBox = self.boundingRect(with: constraintRect, options: NSStringDrawingOptions.usesLineFragmentOrigin, attributes: [NSFontAttributeName: font], context: nil)
  49 +
  50 + return boundingBox.height
  51 + }
  52 +
41 53 }
Morooka.xcworkspace/xcuserdata/ptran.xcuserdatad/UserInterfaceState.xcuserstate
No preview for this file type