Skip to content

Commit

Permalink
Added callback for cancel button
Browse files Browse the repository at this point in the history
  • Loading branch information
sman591 committed Mar 9, 2015
1 parent c74190e commit 0bbbbd1
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions JSSAlertView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class JSSAlertView: UIViewController {
var iconImage:UIImage!
var iconImageView:UIImageView!
var closeAction:(()->Void)!
var cancelAction:(()->Void)!
var isAlertOpen:Bool = false

enum FontType {
Expand Down Expand Up @@ -63,6 +64,10 @@ class JSSAlertView: UIViewController {
self.alertview.addAction(action)
}

func addCancelAction(action: ()->Void) {
self.alertview.addCancelAction(action)
}

func setTitleFont(fontStr: String) {
self.alertview.setFont(fontStr, type: .Title)
}
Expand Down Expand Up @@ -372,6 +377,10 @@ class JSSAlertView: UIViewController {
closeView(true);
}

func addCancelAction(action: ()->Void) {
self.cancelAction = action
}

func cancelButtonTap() {
closeView(false);
}
Expand All @@ -397,6 +406,9 @@ class JSSAlertView: UIViewController {
func removeView() {
isAlertOpen = false
self.view.removeFromSuperview()
if let action = self.cancelAction? {
action()
}
}

}
Expand Down

0 comments on commit 0bbbbd1

Please sign in to comment.