SHARE
TWEET

Untitled

a guest Feb 27th, 2020 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. extension SkeletonPresentable where Self: UIViewController {
  2.    
  3.     func didChangedLoadingState(_ state: Bool) {
  4.         let showWorker =  DispatchWorkItem { [weak self] in
  5.             self?.view.showAnimatedSkeleton(usingColor: .greySoft,
  6.             transition: .crossDissolve(animationDuration))
  7.         }
  8.    
  9.         let hideWorker = DispatchWorkItem { [weak self] in
  10.             self?.view.hideSkeleton(reloadDataAfter: true, transition: .crossDissolve(20.0))
  11.         }
  12.        
  13.         if state {
  14.             DispatchQueue.main.asyncAfter(deadline: .now() + 1, execute: showWorker)
  15.         } else {
  16.             showWorker.cancel()
  17.             DispatchQueue.main.async(execute: hideWorker)
  18.         }
  19.     }
  20. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top