Skip to content

Instantly share code, notes, and snippets.

@runys
Last active April 18, 2019 14:45
Show Gist options
  • Save runys/c3d7c11bb8ed62c5a5dacb58fffd0e14 to your computer and use it in GitHub Desktop.
Save runys/c3d7c11bb8ed62c5a5dacb58fffd0e14 to your computer and use it in GitHub Desktop.
Activity indicator in iOS 11 with Swift 4
// Create the Activity Indicator
let activityIndicator = UIActivityIndicatorView(activityIndicatorStyle: .gray)
// Add it to the view where you want it to appear
view.addSubview(activityIndicator)
// Set up its size (the super view bounds usually)
activityIndicator.frame = view.bounds
// Start the loading animation
activityIndicator.startAnimating()
// To remove it, just call removeFromSuperview()
activityIndicator.removeFromSuperview()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment