From bef105decd16e7e055ea5870f6017483518dbfa2 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 19 Mar 2019 13:13:18 -0400 Subject: [PATCH] gif view to swift --- MVMCoreUI/Atoms/Views/MFTransparentGIFView.swift | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/MFTransparentGIFView.swift b/MVMCoreUI/Atoms/Views/MFTransparentGIFView.swift index 3556dcb4..f6f26204 100644 --- a/MVMCoreUI/Atoms/Views/MFTransparentGIFView.swift +++ b/MVMCoreUI/Atoms/Views/MFTransparentGIFView.swift @@ -8,7 +8,7 @@ import UIKit -@objcMembers public class MFTransparentGifView: FLAnimatedImageView { +@objcMembers public class MFTransparentGIFView: FLAnimatedImageView { var imageData: Data? /** Creates the GIF display view with the passed in frame. @@ -19,16 +19,20 @@ import UIKit LoopCompletionBlock: a block called whenever the gif finishes a loop. animatedImage : set as nil when use this view in reusable cell */ - init(withFrame frame: CGRect, imageName: String, startImmediately: Bool, duration: TimeInterval, loopCompletionBlock: ((UInt) -> Void)?) { + @objc public init(withFrame frame: CGRect, imageName: String, startImmediately: Bool, duration: TimeInterval, loopCompletionBlock: ((UInt) -> Void)?) { + super.init(frame: frame) + loadImage(imageName, startImmediately: startImmediately, duration: duration, loopCompletionBlock: loopCompletionBlock) + } + + public override init(frame: CGRect) { super.init(frame: frame) - loadImage(imageName: imageName, startImmediately: startImmediately, duration: duration, loopCompletionBlock: loopCompletionBlock) } required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) } - func loadImage(imageName: String, startImmediately: Bool, duration: TimeInterval, loopCompletionBlock: ((UInt) -> Void)?) { + func loadImage(_ imageName: String, startImmediately: Bool, duration: TimeInterval, loopCompletionBlock: ((UInt) -> Void)?) { contentMode = UIView.ContentMode.scaleAspectFill clipsToBounds = true @@ -52,7 +56,7 @@ import UIKit } } - func loadGifWithData(imageData: Data) { + public func loadGifWithData(_ imageData: Data) { contentMode = UIView.ContentMode.scaleAspectFill clipsToBounds = true backgroundColor = .clear @@ -61,7 +65,7 @@ import UIKit performAnimations() } - func performAnimations() { + public func performAnimations() { animatedImage = FLAnimatedImage(animatedGIFData: imageData, optimalFrameCacheSize: 250, predrawingEnabled: true) } }