daily pastebin goal
71%
SHARE
TWEET

Untitled

a guest Jan 18th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @objc extension UIAlertController {
  2.  
  3. static func showAlert(title: String?, message: String? = nil, closeActionTitle: String? = "OK", preferredStyle: UIAlertControllerStyle = .alert, actions: [UIAlertAction]? = nil) {
  4.         let alertController = UIAlertController(title: title,
  5.                                                 message: message,
  6.                                                 preferredStyle: preferredStyle)
  7.         var allActions = [UIAlertAction]()
  8.         if let closeTitle = closeActionTitle {
  9.             allActions.append(UIAlertAction(title: closeTitle, style: .cancel))
  10.         }
  11.         allActions.append(contentsOf: actions ?? [])
  12.         allActions.forEach { alertController.addAction($0) }
  13.  
  14.         let vc = ClearViewController()
  15.         let window = UIWindow(frame: UIScreen.main.bounds)
  16.         window.rootViewController = vc
  17.         window.backgroundColor = AppTheme.color.clear
  18.         window.windowLevel = UIWindowLevelAlert
  19.  
  20.     DispatchQueue.main.async {
  21.         window.makeKeyAndVisible()
  22.         vc.present(alertController, animated: true)
  23.     }
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top