Sha256: fb1f28b80da0a735a5f430307877fc8770e23142d86e3a5a7b507e56f862317e

Contents?: true

Size: 995 Bytes

Versions: 54

Compression:

Stored size: 995 Bytes

Contents

module SugarCube
  # Easily get and set UIView or CALayer frame properties
  #
  # UIView and CALayer both have a 'frame' property that you can edit or access
  # using these methods. Written as a module so we don't have to copy/paste the
  # code into both classes.
  module Frameable

    def x
      self.frame.origin.x
    end

    def setX(newX)
      new_frame = self.frame
      new_frame.origin.x = newX
      self.frame = new_frame
    end

    def y
      self.frame.origin.y
    end

    def setY(newY)
      new_frame = self.frame
      new_frame.origin.y = newY
      self.frame = new_frame
    end

    def height
      self.frame.size.height
    end

    def setHeight(newHeight)
      new_frame = self.frame
      new_frame.size.height = newHeight
      self.frame = new_frame
    end

    def width
      self.frame.size.width
    end

    def setWidth(newWidth)
      new_frame = self.frame
      new_frame.size.width = newWidth
      self.frame = new_frame
    end

  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
sugarcube-4.0.0 lib/cocoa/sugarcube-ui/frameable.rb
sugarcube-3.5.0 lib/cocoa/sugarcube-ui/frameable.rb
sugarcube-3.4.2 lib/cocoa/sugarcube-ui/frameable.rb
sugarcube-3.4.1 lib/cocoa/sugarcube-ui/frameable.rb
sugarcube-3.4.0 lib/cocoa/sugarcube-ui/frameable.rb
sugarcube-3.3.7 lib/cocoa/sugarcube-ui/frameable.rb
sugarcube-3.3.6 lib/cocoa/sugarcube-ui/frameable.rb
sugarcube-3.3.5 lib/cocoa/sugarcube-ui/frameable.rb
sugarcube-3.3.4 lib/cocoa/sugarcube-ui/frameable.rb
sugarcube-3.3.3 lib/cocoa/sugarcube-ui/frameable.rb
sugarcube-3.3.2 lib/cocoa/sugarcube-ui/frameable.rb
sugarcube-3.3.1 lib/cocoa/sugarcube-ui/frameable.rb
sugarcube-3.3.0 lib/cocoa/sugarcube-ui/frameable.rb
sugarcube-3.2.0 lib/cocoa/sugarcube-ui/frameable.rb
sugarcube-3.1.1 lib/cocoa/sugarcube-ui/frameable.rb
sugarcube-3.1.0 lib/cocoa/sugarcube-ui/frameable.rb
sugarcube-3.0.8 lib/cocoa/sugarcube-ui/frameable.rb
sugarcube-3.0.7 lib/cocoa/sugarcube-ui/frameable.rb
sugarcube-3.0.6 lib/cocoa/sugarcube-ui/frameable.rb
sugarcube-3.0.5 lib/cocoa/sugarcube-ui/frameable.rb