Skip to content

Instantly share code, notes, and snippets.

@magnuskahr
Created May 29, 2019 10:55
Show Gist options
  • Save magnuskahr/420820979b9ae565281a602f22cc2296 to your computer and use it in GitHub Desktop.
Save magnuskahr/420820979b9ae565281a602f22cc2296 to your computer and use it in GitHub Desktop.
Showing an ActivityIndicator in a Alert
let alert = UIAlertController(title: "Sender ...", message: nil, preferredStyle: .alert)
let activityIndicator = UIActivityIndicatorView(style: .gray)
activityIndicator.translatesAutoresizingMaskIntoConstraints = false
activityIndicator.isUserInteractionEnabled = false
activityIndicator.startAnimating()
alert.view.addSubview(activityIndicator)
alert.view.heightAnchor.constraint(equalToConstant: 95).isActive = true
activityIndicator.centerXAnchor.constraint(equalTo: alert.view.centerXAnchor, constant: 0).isActive = true
activityIndicator.bottomAnchor.constraint(equalTo: alert.view.bottomAnchor, constant: -20).isActive = true
present(alert, animated: true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment