Last active
November 23, 2018 21:38
-
-
Save Ibrahimhass/dfe9f868041ee4bf9461b85c55f5d7c0 to your computer and use it in GitHub Desktop.
SVIndefiniteAnimatedView Code for adding UIActivityIndicatorView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//MARK: - ActivityIndicatorView Functions | |
extension IndefiniteAnimatedView { | |
func removeAnimationLayer() { | |
for view in self.subviews { | |
if let activityView = view as? UIActivityIndicatorView { | |
activityView.removeFromSuperview() | |
} | |
} | |
getIndefinteAnimatedLayer().removeFromSuperlayer() | |
} | |
func startAnimation() { | |
if let activityIndicator = activityIndicator { | |
self.addSubview(activityIndicator) | |
activityIndicator.frame = CGRect.init(x: 8, y: 8, width: self.frame.size.width - 16, height: self.frame.size.height - 16) | |
} | |
} | |
func stopActivityIndicator() { | |
activityIndicator?.stopAnimating() | |
} | |
func setActivityIndicator(color: UIColor) { | |
activityIndicator = UIActivityIndicatorView.init(style: .whiteLarge) | |
activityIndicator?.hidesWhenStopped = true | |
activityIndicator?.startAnimating() | |
activityIndicator?.color = color | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment