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-2.4.2 lib/cocoa/sugarcube-cocoakit/frameable.rb
sugarcube-2.4.1 lib/cocoa/sugarcube-cocoakit/frameable.rb
sugarcube-2.4.0 lib/cocoa/sugarcube-cocoakit/frameable.rb
sugarcube-2.3.0 lib/cocoa/sugarcube-cocoakit/frameable.rb
sugarcube-2.2.0 lib/cocoa/sugarcube-cocoakit/frameable.rb
sugarcube-2.1.5 lib/cocoa/sugarcube-cocoakit/frameable.rb
sugarcube-2.1.4 lib/cocoa/sugarcube-cocoakit/frameable.rb
sugarcube-2.1.3 lib/cocoa/sugarcube-cocoakit/frameable.rb
sugarcube-2.1.2 lib/cocoa/sugarcube-cocoakit/frameable.rb
sugarcube-2.1.1 lib/cocoa/sugarcube-cocoakit/frameable.rb
sugarcube-2.1.0 lib/cocoa/sugarcube-cocoakit/frameable.rb
sugarcube-2.0.2 lib/cocoa/sugarcube-cocoakit/frameable.rb
sugarcube-2.0.1 lib/cocoa/sugarcube-cocoakit/frameable.rb
sugarcube-2.0.0 lib/cocoa/sugarcube-cocoakit/frameable.rb