-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathViewController.swift
76 lines (66 loc) · 3.05 KB
/
ViewController.swift
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
74
75
76
//
// ViewController.swift
// SSSpinnerButton
//
// Created by Bhargav Bajani on 05/06/18.
// Copyright © 2018 Simform Solutions. All rights reserved.
//
import UIKit
import SSSpinnerButton
class ViewController: UIViewController {
// MARK: Outlets
@IBOutlet weak var btnClipRotate: SSSpinnerButton!
@IBOutlet weak var btnSpinFade: SSSpinnerButton!
@IBOutlet weak var btnLineSpinFade: SSSpinnerButton!
@IBOutlet weak var btnBallRotateChase: SSSpinnerButton!
@IBOutlet weak var btnCircleStrokeSpin: SSSpinnerButton!
@IBOutlet weak var btnRippleEffect: SSSpinnerButton!
override func viewDidLoad() {
super.viewDidLoad()
btnRippleEffect.setRippleEffect(rippleEffectAnimationDuration: 0.3, initialOpacity: 0.5, rippleEffectColor: .black, rippleEffectPercent: 0.45, initialRippleEffectPercent: 0.3)
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func onSpinnnerButtonClick(_ sender: SSSpinnerButton) {
let arr: [SpinnerType] = [.ballClipRotate, .ballSpinFade, .lineSpinFade, .ballRotateChase, .circleStrokeSpin, .ballClipRotate, .ballSpinFade, .lineSpinFade, .ballRotateChase, .pacman, .circleScaleMultiple, .circleWaveSpin]
// MARK: Start Animating
sender.startAnimate(spinnerType: arr[sender.tag], spinnercolor: .white, spinnerSize: 20, complete: nil)
Timer.scheduledTimer(withTimeInterval: 5, repeats: false) { (_) in
if sender.tag == 5 {
// MARK: Stop Animating with completion type and back to default
// MARK: completion type is fail
sender.stopAnimatingWithCompletionType(completionType: .fail, complete: {
// Your completion actions
})
return
}
if sender.tag == 6 {
// MARK: Stop Animating with completion type and back to default
// MARK: completion type is fail
sender.stopAnimationWithCompletionTypeAndBackToDefaults(completionType: .fail, backToDefaults: true, complete: {
// Your completion actions
})
return
}
if sender.tag == 7 {
// MARK: Stop animating with completion type
// MARK: completion type is success
sender.stopAnimatingWithCompletionType(completionType: .success, complete: nil)
return
}
if sender.tag == 8 {
// MARK: Stop animating with completion type
// MARK: completion type is error
sender.stopAnimatingWithCompletionType(completionType: .error, complete: nil)
return
}
// MARK: Stop animating without completion
sender.stopAnimate(complete: {
// Your completion actions
})
}
}
}