SpinnerView animation freezing fix

This commit is contained in:
Anton Popkov 2018-06-07 16:49:17 +03:00
parent 37b4c72374
commit f20f355a42
3 changed files with 17 additions and 6 deletions

View File

@ -1,5 +1,9 @@
# Changelog
### 0.8.3
- **Fix**: `SpinnerView` animation freezing
### 0.8.2
- **Add**: `acceptableStatusCodes` property to `NetworkServiceConfiguration`

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "LeadKit"
s.version = "0.8.2"
s.version = "0.8.3"
s.summary = "iOS framework with a bunch of tools for rapid development"
s.homepage = "https://github.com/TouchInstinct/LeadKit"
s.license = "Apache License, Version 2.0"

View File

@ -24,7 +24,10 @@ import UIKit
public final class SpinnerView: UIView, Animatable, LoadingIndicator {
private(set) var animating: Bool = false
private var animating: Bool {
return imageView?.layer.animation(forKey: CABasicAnimation.rotationKeyPath) != nil
}
private var startTime = CFTimeInterval(0)
private var stopTime = CFTimeInterval(0)
@ -80,6 +83,14 @@ public final class SpinnerView: UIView, Animatable, LoadingIndicator {
}
}
override public func didMoveToSuperview() {
super.didMoveToSuperview()
if superview != nil {
restartAnimationIfNeeded()
}
}
// MARK: - Animatable
@objc public func startAnimating() {
@ -87,8 +98,6 @@ public final class SpinnerView: UIView, Animatable, LoadingIndicator {
return
}
animating = true
imageView?.isHidden = false
addAnimation()
@ -99,8 +108,6 @@ public final class SpinnerView: UIView, Animatable, LoadingIndicator {
return
}
animating = false
imageView?.isHidden = true
removeAnimation()