Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nguyentruongky/a29f075f54c69443d1c183fed2febf54 to your computer and use it in GitHub Desktop.
Save nguyentruongky/a29f075f54c69443d1c183fed2febf54 to your computer and use it in GitHub Desktop.
Show indicator view inside UIButton
func setProcess(visible: Bool,
style: UIActivityIndicatorView.Style = .white) {
if visible {
titleLabel?.layer.opacity = 0
isEnabled = false
let indicator = UIActivityIndicatorView(style: style)
indicator.translatesAutoresizingMaskIntoConstraints = false
indicator.tag = 12398137
indicator.startAnimating()
addSubview(indicator)
indicator.center(toView: self)
} else {
titleLabel?.layer.opacity = 1
isEnabled = true
let indicator = viewWithTag(12398137)
indicator?.removeFromSuperview()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment