-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNTPLoading.swift
More file actions
41 lines (36 loc) · 1.46 KB
/
NTPLoading.swift
File metadata and controls
41 lines (36 loc) · 1.46 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
/*
* @package NTPLoading.swift
* @author The Phuc
* @since 7/10/2016.
*/
import Foundation
import UIKit
class NTPLoading {
var loadingView = UIView()
var activityIndicator = UIActivityIndicatorView()
func show() {
let win:UIWindow = UIApplication.sharedApplication().delegate!.window!!
self.loadingView = UIView(frame: win.frame)
self.loadingView.tag = 1
self.loadingView.backgroundColor = UIColor(red: 255/255, green: 255/255, blue: 255/255, alpha: 0)
win.addSubview(self.loadingView)
activityIndicator.frame = CGRectMake(0, 0, win.frame.width/5, win.frame.width/5)
activityIndicator.activityIndicatorViewStyle = .WhiteLarge
activityIndicator.center = self.loadingView.center
activityIndicator.color = UIColor.blackColor()
self.loadingView.addSubview(activityIndicator)
activityIndicator.startAnimating()
}
func hide(){
UIView.animateWithDuration(0.0, delay: 1.0, options: .CurveEaseOut, animations: {
self.loadingView.alpha = 0.0
self.activityIndicator.stopAnimating()
}, completion: { finished in
self.activityIndicator.removeFromSuperview()
self.loadingView.removeFromSuperview()
let win:UIWindow = UIApplication.sharedApplication().delegate!.window!!
let removeView = win.viewWithTag(1)
removeView?.removeFromSuperview()
})
}
}