Skip to content

Instantly share code, notes, and snippets.

@masuhara
Created November 22, 2015 08:02
Show Gist options
  • Save masuhara/380fcae211f453792144 to your computer and use it in GitHub Desktop.
Save masuhara/380fcae211f453792144 to your computer and use it in GitHub Desktop.
Button Pop Animation with CABasicAnimation written in Swift
// Button Animation
@IBAction func pushButton(button: UIButton) {
// CABasicAnimation
let animation = CABasicAnimation(keyPath: "transform")
animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
animation.duration = 0.05
animation.repeatCount = 1
animation.autoreverses = true
animation.removedOnCompletion = true
animation.toValue = NSValue(CATransform3D: CATransform3DMakeScale(1.1, 1.1, 1.0))
button.layer.addAnimation(animation, forKey: nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment