class CALayer

Public Instance Methods

<<(layer) click to toggle source
# File lib/cocoa/sugarcube-ui/calayer.rb, line 3
def << (layer)
  self.addSublayer layer
  return self
end
basic_animation(key_path, options={}) click to toggle source
# 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
keyframe_animation(key_path, options={}) click to toggle source
# File lib/cocoa/sugarcube-animations/calayer.rb, line 24
def keyframe_animation(key_path, options={})
  animation = CAAnimation.keyframe(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?(:values)
    self.setValue(options[:values].last, forKeyPath: key_path)
  end

  return animation
end
sugarcube_to_s(options={}) click to toggle source
# File lib/cocoa/sugarcube-to_s/calayer.rb, line 3
def sugarcube_to_s(options={})
  if options[:inner].is_a? Hash
    inner = ''
    options[:inner].each do |key, value|
      inner += ', ' if inner.length > 0
      inner += "#{key}: #{value.inspect}"
    end
  else
    inner = options[:inner]
  end

  "#{self.class.to_s}(##{self.object_id.to_s(16)}, [[#{frame.origin.x}, #{frame.origin.y}], [#{frame.size.width}, #{frame.size.height}]])"
end
to_s() click to toggle source
# File lib/cocoa/sugarcube-to_s/calayer.rb, line 17
def to_s
  sugarcube_to_s
end
unshift(layer) click to toggle source
# File lib/cocoa/sugarcube-ui/calayer.rb, line 8
def unshift(layer)
  self.insertSublayer(layer, atIndex:0)
  return self
end