SwiftySVGAPlayer is a high level APIs based on SVGAPlayer, which support play svga according url or local svga data, default push svga in FIFO queue, and then pop to play, and you can set isInstant true for cancel the queue.
pod 'SwiftySVGAPlayer', '1.4.5'
just one line code to play svga:(Please run on iOS device)
// for example in a controller:
SwiftySVGAPlayer().pushToPlay(svga: "https://xxx/filename.svga", on: self.view)
// Warning: Playing a svga maybe slow for the first time, you could batch cache svgas in some place like after app launch or log in before play them
SwiftySVGAPlayer().cache(svga: "https://xxx/filename.svga")
// Optional: ----------------------------------------------------
// detail properties and methods
/// Whether user interaction enabled when play svga
public var isUserInteractionEnabled: Bool
/// Whether add shadow mask when play svga
public var isMask: Bool
/// Whether play a single svga forever
public var isInfinite: Bool
/// Add svga urlstring or svgadata's base64string to FIFO queue and pop to play
open func play(svga urlString: String, on view: UIView, isInstant: Bool = false, scale: CGFloat = 1)
/// prepare to cache for svga url
public func cache(svga urlString: String, failure: ((Error) -> Void)? = nil)
/// reset player to inital state
open func clear()
/// other methods for example pause/stop/play and so on, please see the demo in rep
- iOS 9.0+
- Swift 4.2 to 5.1
Visit my github: janlionly
Contact with me by email: [email protected]
I would love you to contribute to SwiftySVGAPlayer
SwiftySVGAPlayer is available under the Apache 2.0 license. See the LICENSE file for more info.