Class: CAAnimation
Class Method Summary collapse
-
.basic(key_path, options = {}, &block) ⇒ Object
If you pass a block, that block will be called at the end of the animation.
- .keyframe(key_path, options = {}, &block) ⇒ Object
Class Method Details
.basic(key_path, options = {}, &block) ⇒ Object
If you pass a block, that block will be called at the end of the animation.
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/sugarcube-animations/caanimation.rb', line 17 def basic(key_path, ={}, &block) animation = CABasicAnimation.animationWithKeyPath(key_path) (animation, ) if .key?(:from) || .key?(:to) || .key?(:by) animation.fromValue = [:from] if .key?(:from) animation.toValue = [:to] if .key?(:to) animation.byValue = [:by] if .key?(:by) end return animation end |
.keyframe(key_path, options = {}, &block) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/sugarcube-animations/caanimation.rb', line 30 def keyframe(key_path, ={}, &block) timing_function = .fetch(:timing, KCAMediaTimingFunctionDefault) if timing_function.is_a?(NSString) timing_function = CAMediaTimingFunction.functionWithName(timing_function) end fill_mode = .fetch(:fill_mode, KCAFillModeForwards) animation = CAKeyframeAnimation.animationWithKeyPath(key_path) (animation, ) animation.timingFunction = timing_function animation.fillMode = fill_mode if .key?(:values) animation.values = [:values] elsif .key?(:path) animation.path = [:path] end return animation end |