Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Foundation
- import UIKit
- import SnapKit
- protocol Spinnable where Self: UIViewController {
- func showActivityIndicator()
- func hideActivityIndicator()
- }
- extension Spinnable {
- func showActivityIndicator() {
- let activityIndicator = UIActivityIndicatorView()
- self.view.addSubview(activityIndicator)
- activityIndicator.snp.makeConstraints { (make) in
- make.centerX.centerY.equalToSuperview()
- make.width.height.equalTo(50)
- }
- }
- func hideActivityIndicator() {
- for view in self.view.subviews {
- guard let activityIndicator = view as? UIActivityIndicatorView else {
- continue
- }
- activityIndicator.removeFromSuperview()
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement