Shake Animation

func shakeAnimation() { let animation = CABasicAnimation(keyPath: "position") animation.duration = 0.07 animation.repeatCount = 3 animation.autoreverses = true animation.fromValue = NSValue(CGPoint: CGPointMake( - 5, animation.toValue = NSValue(CGPoint: CGPointMake( + 5, self.layer.addAnimation(animation, forKey: "position") }
Include this in an Extension of UIView

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.