Skip to content

Instantly share code, notes, and snippets.

@nobodyiscertain
Created November 11, 2014 04:40
Show Gist options
  • Save nobodyiscertain/4a04e97917c91ddc2fca to your computer and use it in GitHub Desktop.
Save nobodyiscertain/4a04e97917c91ddc2fca to your computer and use it in GitHub Desktop.
CATransaction Completion Block
def logo_view_was_tapped
CATransaction.begin
timing = CAMediaTimingFunction.send('functionWithControlPoints::::', 0.28, -0.3, 0.12, 1.0)
rotateAnimation = CABasicAnimation.animationWithKeyPath("transform.rotation")
rotateAnimation.toValue = Math::PI / 180 * 720
rotateAnimation.duration = 2.0
rotateAnimation.timingFunction = timing
CATransaction.setCompletionBlock lambda {
# Fancy code to run when completed
}
@logo_view.layer.addAnimation(rotateAnimation, forKey: :logo_spinning)
CATransaction.commit
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment