SwiftySVGAPlayer
说明
SwiftySVGAPlayer 是基于 SVGAPlayer 的高级 API,支持通过 URL 或本地 SVGA 数据播放 SVGA,默认先将 SVGA 推送到先入先出队列中,然后出队进行播放,您可以通过设置 isInstant 为 true 来取消队列。
安装
CocoaPods
pod 'SwiftySVGAPlayer'
用法
只需一行代码即可播放 SVGA
// 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 到 5.1
作者
访问我的 GitHub: janlionly
通过电子邮件与我联系:[email protected]
贡献
我很乐意您为 SwiftySVGAPlayer 做贡献
授权许可
SwiftySVGAPlayer 可在 Apache 2.0 许可证下使用。有关更多信息,请参阅授权许可文件。