试图在iOS上使用FBShimmer可可豆荚,但没有找到Foundation框架

时间:2017-11-11 09:59:39

标签: ios cocoapods

我正在尝试在iOS上使用FBShimmer cocoa pod但没有找到Foundation框架。Github Rate Limits

PodFile shown here

enter image description here

1 个答案:

答案 0 :(得分:0)

我最终只是使用UIView扩展来实现相同的效果。更少的代码和没有外部依赖。

func startShimmering() {
    let light = UIColor(red: 0, green: 0, blue: 0, alpha: 0.5).cgColor
    let dark = UIColor.white.cgColor

    let gradient: CAGradientLayer = CAGradientLayer()
    gradient.colors = [dark, light, dark]
    gradient.frame = CGRect(x: -self.bounds.size.width, y: 0, width: 3*self.bounds.size.width, height: self.bounds.size.height)
    gradient.startPoint = CGPoint(x: 0.0, y: 0.4)
    gradient.endPoint = CGPoint(x: 1.0, y: 0.5)
    gradient.locations = [0.4, 0.5, 0.6]
    self.layer.mask = gradient

    let animation: CABasicAnimation = CABasicAnimation(keyPath: "locations")
    animation.fromValue = [0.0, 0.1, 0.2]
    animation.toValue = [0.8, 0.9, 1.0]

    animation.duration = 3.0
    animation.repeatCount = HUGE
    gradient.add(animation, forKey: "shimmer")


}