KingFisher 的 AnimatedImageView,做 gif 动画,先暂停
代码部分:
lazy var animatedPart: AnimatedImageView = {
let img = AnimatedImageView()
if let src = Bundle.main.url(forResource: "xx", withExtension: "gif"){
img.kf.setImage(with: src)
}
return img
}()
var bePaused = true{
didSet{
if bePaused{
animatedPart.stopAnimating()
}
else{
animatedPart.startAnimating()
}
}
}
关闭默认动画
处理 AnimatedImageView.swift
文件:
删掉一行 didMove()
// Reset the animator.
private func reset() {
animator = nil
if let imageSource = image?.kf.imageSource {
let targetSize = bounds.scaled(UIScreen.main.scale).size
let animator = Animator(
imageS