diff --git a/APNGKit/APNGImageView.swift b/APNGKit/APNGImageView.swift index a7a66f5..80adeae 100644 --- a/APNGKit/APNGImageView.swift +++ b/APNGKit/APNGImageView.swift @@ -64,6 +64,11 @@ public class APNGImageView: UIView { } } + // If true runs animation timer with option: NSRunLoopCommonModes + // ScrollView(CollectionView, TableView) items with Animated APNGImageView will not freez during scrolling + // Warning: this may decrease scrolling smoothness with lot's of animations + public var allowAnimationInScrollView = false + var timer: CADisplayLink? var lastTimestamp: NSTimeInterval = 0 var currentPassedDuration: NSTimeInterval = 0 @@ -137,7 +142,7 @@ public class APNGImageView: UIView { timer = CADisplayLink.apng_displayLink({ [weak self] (displayLink) -> () in self?.tick(displayLink) }) - timer?.addToRunLoop(mainRunLoop, forMode: NSDefaultRunLoopMode) + timer?.addToRunLoop(mainRunLoop, forMode: (self.allowAnimationInScrollView ? NSRunLoopCommonModes : NSDefaultRunLoopMode)) } /** diff --git a/APNGKitDemo/Base.lproj/LaunchScreen.storyboard b/APNGKitDemo/Base.lproj/LaunchScreen.storyboard index 4697131..d2f6432 100644 --- a/APNGKitDemo/Base.lproj/LaunchScreen.storyboard +++ b/APNGKitDemo/Base.lproj/LaunchScreen.storyboard @@ -1,7 +1,8 @@ - + - + + @@ -23,7 +24,6 @@ -