-
Notifications
You must be signed in to change notification settings - Fork 295
Expand file tree
/
Copy pathViewController.swift
More file actions
74 lines (54 loc) · 2.99 KB
/
ViewController.swift
File metadata and controls
74 lines (54 loc) · 2.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//
// ViewController.swift
// SweetAlert
//
// Created by Codester on 11/3/14.
// Copyright (c) 2014 Codester. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
var alert = SweetAlert()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.view.backgroundColor = UIColor(red: 242.0/255.0, green: 244.0/255.0, blue: 246.0/255.0, alpha: 1.0)
}
override func viewDidAppear(_ animated: Bool) {
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func aBasicMessageAlert(_ sender: AnyObject) {
_ = SweetAlert().showAlert("Here's a message!", EnabledOutsideTap: false)
}
@IBAction func subtitleAlert(_ sender: AnyObject) {
_ = SweetAlert().showAlert("Here's a message!", subTitle: "It's pretty, isn't it?", style: AlertStyle.none, EnabledOutsideTap: true)
}
@IBAction func sucessAlert(_ sender: AnyObject) {
_ = SweetAlert().showAlert("Good job!", subTitle: "You clicked the button!", style: AlertStyle.success, EnabledOutsideTap: true)
}
@IBAction func warningAlert(_ sender: AnyObject) {
_ = SweetAlert().showAlert("Are you sure?", subTitle: "You file will permanently delete!", style: AlertStyle.warning, buttonTitle:"Cancel", buttonColor:UIColor.colorFromRGB(0xD0D0D0) , otherButtonTitle: "Yes, delete it!",otherButtonColor: UIColor.colorFromRGB(0xDD6B55), EnabledOutsideTap: true) { (isOtherButton) -> Void in
if isOtherButton == true {
print("Cancel Button Pressed", terminator: "")
}
else {
_ = SweetAlert().showAlert("Deleted!", subTitle: "Your imaginary file has been deleted!", style: AlertStyle.success, EnabledOutsideTap: true)
}
}
}
@IBAction func cancelAndConfirm(_ sender: AnyObject) {
_ = SweetAlert().showAlert("Are you sure?", subTitle: "You file will permanently delete!", style: AlertStyle.warning, buttonTitle:"No, cancel plx!", buttonColor:UIColor.colorFromRGB(0xD0D0D0) , otherButtonTitle: "Yes, delete it!", otherButtonColor: UIColor.colorFromRGB(0xDD6B55), EnabledOutsideTap: true) { (isOtherButton) -> Void in
if isOtherButton == true {
_ = SweetAlert().showAlert("Cancelled!", subTitle: "Your imaginary file is safe", style: AlertStyle.error, EnabledOutsideTap: true)
}
else {
_ = SweetAlert().showAlert("Deleted!", subTitle: "Your imaginary file has been deleted!", style: AlertStyle.success, EnabledOutsideTap: true)
}
}
}
@IBAction func customIconAlert(_ sender: AnyObject) {
_ = SweetAlert().showAlert("Sweet!", subTitle: "Here's a custom image.", style: AlertStyle.customImage(imageFile: "thumb.jpg"), EnabledOutsideTap: true)
}
}