-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathLoadingViewController.swift
46 lines (38 loc) · 1.56 KB
/
LoadingViewController.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
//
// LoadingViewController.swift
// FOSSAsia
//
// Created by Jurvis Tan on 12/2/16.
// Copyright © 2016 FossAsia. All rights reserved.
//
import UIKit
class LoadingViewController: UIViewController {
struct StoryboardConstants {
static let storyboardName = Constants.sessionsStoryboardName
static let viewControllerId = String(describing: LoadingViewController.self)
}
lazy var loadAnimating = true
@IBOutlet weak var loadingImageView: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
// self.spinLoadingIndicatorWithOptions(UIViewAnimationOptions())
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
// moved spinLoadingIndicatorWithOptions from viewDidLoad to viewDidAppear
self.spinLoadingIndicatorWithOptions(UIViewAnimationOptions())
}
fileprivate func spinLoadingIndicatorWithOptions(_ options: UIViewAnimationOptions) {
UIView.animate(withDuration: 0.15, delay: 0, options: options, animations: { () -> Void in
self.loadingImageView.transform = self.loadingImageView.transform.rotated(by: CGFloat(Double.pi / 2))
}) { (finished) -> Void in
if finished {
if self.loadAnimating {
self.spinLoadingIndicatorWithOptions([.curveLinear])
} else if (options != UIViewAnimationOptions()) {
self.spinLoadingIndicatorWithOptions(UIViewAnimationOptions())
}
}
}
}
}