let indicator = self.funcs.showLoadingAnimation(view)
//dismiss
self.funcs.dismissLoadingAnimation(indicator.0, viewActivityIndicator: indicator.1, blurEffectView: indicator.2)
func showLoadingAnimation(view:UIView) -> ( UIActivityIndicatorView, UIView, UIVisualEffectView) {
var activityIndicator: UIActivityIndicatorView!
var viewActivityIndicator: UIView!
let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.Light)
let blurEffectView = UIVisualEffectView(effect: blurEffect)
blurEffectView.frame = view.bounds
blurEffectView.autoresizingMask = [.FlexibleWidth, .FlexibleHeight] // for supporting device rotation
blurEffectView.alpha = 0.99
view.addSubview(blurEffectView)
let width: CGFloat = 200.0
let height: CGFloat = 50.0
let x = view.frame.width/2.0 - width/2.0
let y = view.frame.height/2.0 - height/2.0
viewActivityIndicator = UIView(frame: CGRect(x: x, y: y, width: width, height: height))
viewActivityIndicator.backgroundColor = UIColor(red: 255.0/255.0, green: 204.0/255.0, blue: 51.0/255.0, alpha: 0.5)
viewActivityIndicator.layer.cornerRadius = 10
activityIndicator = UIActivityIndicatorView(frame: CGRect(x: 0, y: 0, width: 50, height: 50))
activityIndicator.color = UIColor.blackColor()
activityIndicator.hidesWhenStopped = false
let titleLabel = UILabel(frame: CGRect(x: 60, y: 0, width: 200, height: 50))
titleLabel.text = "Yükleniyor..."
viewActivityIndicator.addSubview(activityIndicator)
viewActivityIndicator.addSubview(titleLabel)
view.addSubview(viewActivityIndicator)
activityIndicator.startAnimating()
UIApplication.sharedApplication().beginIgnoringInteractionEvents()
return (activityIndicator, viewActivityIndicator, blurEffectView)
}
func dismissLoadingAnimation (activityIndicator:UIActivityIndicatorView, viewActivityIndicator:UIView, blurEffectView:UIVisualEffectView) {
activityIndicator.stopAnimating()
UIApplication.sharedApplication().endIgnoringInteractionEvents()
viewActivityIndicator.removeFromSuperview()
blurEffectView.removeFromSuperview()
}