Created
April 3, 2013 02:24
-
-
Save twerth/5297956 to your computer and use it in GitHub Desktop.
RubyMotion: Adding a block to Teacup's animate_to_style, for completion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# RubyMotion: Adding a block to Teacup's animate_to_style, for completion. You can do something like this | |
# | |
# popup.animate_to_style( duration: 0.9, left: 5) do |finished| | |
# popup.animate_to_style( duration: 0.3, left: 105) do |finished| | |
# popup.animate_to_style( duration: 0.5, top: 300) do |finished| | |
# popup.hidden = true | |
# end | |
# end | |
# end | |
# | |
class UIView | |
def animate_to_style(opts = {}, &block) | |
UIView.animateWithDuration( | |
opts.delete(:duration) || 0.3, | |
delay: opts.delete(:delay) || 0, | |
options: (opts.delete(:options) || UIViewAnimationOptionCurveEaseInOut), | |
animations: lambda { style(opts) }, | |
completion: block) | |
self | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment