Skip to content

Instantly share code, notes, and snippets.

@Ibrahimhass
Last active November 23, 2018 21:38
Show Gist options
  • Save Ibrahimhass/dfe9f868041ee4bf9461b85c55f5d7c0 to your computer and use it in GitHub Desktop.
Save Ibrahimhass/dfe9f868041ee4bf9461b85c55f5d7c0 to your computer and use it in GitHub Desktop.
SVIndefiniteAnimatedView Code for adding UIActivityIndicatorView
//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