Procházet zdrojové kódy

Merge pull request #1350 from onevcat/fix/gif-repeat-count

Fix wrong repeatCount calculation in AnimatedImageView
Wei Wang před 6 roky
rodič
revize
9ceea6406f
1 změnil soubory, kde provedl 4 přidání a 7 odebrání
  1. 4 7
      Sources/Views/AnimatedImageView.swift

+ 4 - 7
Sources/Views/AnimatedImageView.swift

@@ -31,8 +31,6 @@
 //  The name and characters used in the demo of this software are property of their
 //  The name and characters used in the demo of this software are property of their
 //  respective owners.
 //  respective owners.
 
 
-#if !os(watchOS)
-
 #if canImport(UIKit)
 #if canImport(UIKit)
 import UIKit
 import UIKit
 import ImageIO
 import ImageIO
@@ -534,10 +532,11 @@ extension AnimatedImageView {
 
 
         private func incrementCurrentFrameIndex() {
         private func incrementCurrentFrameIndex() {
             currentFrameIndex = increment(frameIndex: currentFrameIndex)
             currentFrameIndex = increment(frameIndex: currentFrameIndex)
-            if isReachMaxRepeatCount && isLastFrame {
-                isFinished = true
-            } else if currentFrameIndex == 0 {
+            if isLastFrame {
                 currentRepeatCount += 1
                 currentRepeatCount += 1
+                if isReachMaxRepeatCount {
+                    isFinished = true
+                }
                 delegate?.animator(self, didPlayAnimationLoops: currentRepeatCount)
                 delegate?.animator(self, didPlayAnimationLoops: currentRepeatCount)
             }
             }
         }
         }
@@ -612,5 +611,3 @@ class SafeArray<Element> {
     }
     }
 }
 }
 #endif
 #endif
-
-#endif