Module: SugarCube::Frameable
Overview
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.
Instance Method Summary collapse
- #height ⇒ Object
- #setHeight(newHeight) ⇒ Object
- #setWidth(newWidth) ⇒ Object
- #setX(newX) ⇒ Object
- #setY(newY) ⇒ Object
- #width ⇒ Object
- #x ⇒ Object
- #y ⇒ Object
Instance Method Details
#height ⇒ Object
29 30 31 |
# File 'lib/cocoa/sugarcube-ui/frameable.rb', line 29 def height self.frame.size.height end |
#setHeight(newHeight) ⇒ Object
33 34 35 36 37 |
# File 'lib/cocoa/sugarcube-ui/frameable.rb', line 33 def setHeight(newHeight) new_frame = self.frame new_frame.size.height = newHeight self.frame = new_frame end |
#setWidth(newWidth) ⇒ Object
43 44 45 46 47 |
# File 'lib/cocoa/sugarcube-ui/frameable.rb', line 43 def setWidth(newWidth) new_frame = self.frame new_frame.size.width = newWidth self.frame = new_frame end |
#setX(newX) ⇒ Object
13 14 15 16 17 |
# File 'lib/cocoa/sugarcube-ui/frameable.rb', line 13 def setX(newX) new_frame = self.frame new_frame.origin.x = newX self.frame = new_frame end |
#setY(newY) ⇒ Object
23 24 25 26 27 |
# File 'lib/cocoa/sugarcube-ui/frameable.rb', line 23 def setY(newY) new_frame = self.frame new_frame.origin.y = newY self.frame = new_frame end |
#width ⇒ Object
39 40 41 |
# File 'lib/cocoa/sugarcube-ui/frameable.rb', line 39 def width self.frame.size.width end |
#x ⇒ Object
9 10 11 |
# File 'lib/cocoa/sugarcube-ui/frameable.rb', line 9 def x self.frame.origin.x end |
#y ⇒ Object
19 20 21 |
# File 'lib/cocoa/sugarcube-ui/frameable.rb', line 19 def y self.frame.origin.y end |