Я пытаюсь настроить индикатор KingfisherType, но не работает,
Не отображается анимация, появляется только белый фон.
Если вы можете решить эту проблему, большое спасибо.
используйте:
img.kf.indicatorType = .custom(indicator: LoadlidicatorView())
код:
struct LoadlidicatorView: Indicator{
func startAnimatingView() {
view.isHidden = false
animatedImageIndicatorView.startAnimating()
}
func stopAnimatingView() {
view.isHidden = true
animatedImageIndicatorView.stopAnimating()
}
let anination = CABasicAnimation.init(keyPath: "transfrom.translation.x")
var view: IndicatorView {
return animatedImageIndicatorView
}
let gradientLayer = CAGradientLayer()
let animatedImageIndicatorView = UIImageView()
init() {
animatedImageIndicatorView.backgroundColor = UIColor.red
gradientLayer.colors = [UIColor.clear.cgColor,UIColor.white.cgColor,UIColor.clear.cgColor]
gradientLayer.locations = [0, 0.5, 1]
let angle = 45 * CGFloat.pi / 180
gradientLayer.transform = CATransform3DMakeRotation(angle, 0, 0, 1)
animatedImageIndicatorView.layer.mask = gradientLayer
animatedImageIndicatorView.contentMode = .center
anination.duration = 2
anination.fromValue = -animatedImageIndicatorView.frame.width
anination.toValue = animatedImageIndicatorView.frame.width
anination.repeatCount = Float.infinity
gradientLayer.add(anination, forKey: "gradientLayerAnination")
}
}