rv7284
5/3/2017 - 7:02 AM

View extension

View extension

func negativeShake() {
    let animation = CABasicAnimation(keyPath: "position")
    animation.duration = 0.05
    animation.repeatCount = 5
    animation.fromValue = CGPoint(x: self.center.x - 4, y: self.center.y)
    animation.toValue = CGPoint(x: self.center.x + 4, y: self.center.y)
        
    self.layer.add(animation, forKey: "position")
}