Method: CALayer#basic_animation

Defined in:
lib/cocoa/sugarcube-animations/calayer.rb

#basic_animation(key_path, options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/cocoa/sugarcube-animations/calayer.rb', line 3

def basic_animation(key_path, options={})
  animation = CAAnimation.basic(key_path, options)

  should_add = options.fetch(:add, true)
  if should_add
    if should_add.is_a?(NSString)
      name = should_add
    else
      name = key_path
    end

    self.addAnimation(animation, forKey: name)
  end

  if options.key?(:to)
    self.setValue(options[:to], forKeyPath: key_path)
  end

  return animation
end