// インジケータークラス
import UIKit
class IndicatorView: UIView {
static var Indicator = UIActivityIndicatorView(activityIndicatorStyle: .WhiteLarge)
static let baseView = UIView()
static func generateBaseView(parentView: UIView) {
baseView.frame = parentView.bounds
baseView.backgroundColor = UIColor.blackColor()
baseView.alpha = 0.7
Indicator.center = baseView.center
Indicator.startAnimating()
baseView.addSubview(Indicator)
}
static func showIndicator(parentView: UIView?) {
if let parentView = parentView {
generateBaseView(parentView)
parentView.addSubview(baseView)
}
}
static func hideIndicator() {
baseView.removeFromSuperview()
}
}
// 呼び出すところ(NavigationControllerの場合)
IndicatorView.showIndicator(navigationController?.view)
// 呼び出すところ(ViewControllerの場合)
IndicatorView.showIndicator(view)
// 消す時
IndicatorView.hideIndicator()