Guest User

Untitled

a guest
May 22nd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. extension UIViewController {
  2.  
  3. func presentInfoAlert(_ viewcontroller: UIViewController, withTitle title: String = "", message : String, completion: ((String) -> Swift.Void)? = nil) {
  4.  
  5. let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert)
  6.  
  7. let OKAction = UIAlertAction(title: "확인", style: .default) { action in
  8. if completion != nil {
  9. completion!("OK")
  10. }
  11. }
  12.  
  13. alertController.addAction(OKAction)
  14. viewcontroller.present(alertController, animated: true, completion: nil)
  15. }
  16.  
  17. func presentComformAlert(_ viewcontroller: UIViewController, withTitle title: String = "", cancel: String = "취소", ok: String = "확인", message : String, completion: ((String) -> Swift.Void)? = nil) {
  18.  
  19. let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert)
  20.  
  21. let CancelAction = UIAlertAction(title: cancel, style: .default) { action in
  22. if completion != nil {
  23. completion!("Cancel")
  24. }
  25. }
  26. let OKAction = UIAlertAction(title: ok, style: .default) { action in
  27. if completion != nil {
  28. completion!("OK")
  29. }
  30. }
  31.  
  32. alertController.addAction(CancelAction)
  33. alertController.addAction(OKAction)
  34. viewcontroller.present(alertController, animated: true, completion: nil)
  35. }
  36. }
Add Comment
Please, Sign In to add comment