Activity indicator with custom image

后端 未结 10 1299
甜味超标
甜味超标 2021-01-31 05:58

I am loading a UIWebView and in the meantime I wan\'t to show a blank page with this\"spinner\" activity indic

10条回答
  •  春和景丽
    2021-01-31 06:22

    Swift 5.0 version of accepted Answer

    public extension UIImageView {
      func spin(duration: Float) {
        let rotation = CABasicAnimation(keyPath: "transform.rotation")
        rotation.fromValue = 0
        rotation.toValue = 2 * Double.pi
        rotation.duration = 0.7
        rotation.repeatCount = duration
        layer.add(rotation, forKey: "spin")
      }
    
      func stopSpinning() {
        layer.removeAllAnimations()
      }
    }
    

提交回复
热议问题