Class: UIView
- Inherits:
-
Object
- Object
- UIView
- Defined in:
- lib/sugarcube/uiview.rb
Instance Method Summary collapse
- #<<(view) ⇒ Object
- #delta_to(delta, duration = 0.3, options = {}, &after) ⇒ Object
- #fade_out(duration = 0.3, options = {}, &after) ⇒ Object
- #move_to(position, duration = 0.3, options = {}, &after) ⇒ Object
- #to_s ⇒ Object
Instance Method Details
#<<(view) ⇒ Object
5 6 7 |
# File 'lib/sugarcube/uiview.rb', line 5 def <<(view) self.addSubview view end |
#delta_to(delta, duration = 0.3, options = {}, &after) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/sugarcube/uiview.rb', line 37 def delta_to(delta, duration=0.3, ={}, &after) f = self.frame delta = Point(delta) position = Point(f.origin) position.x += delta.x position.y += delta.y UIView.animateWithDuration(duration, delay: [:delay] || 0, options: [:options] || UIViewAnimationOptionCurveLinear, animations: proc{ f = self.frame f.origin = position self.frame = position }, completion:after ) end |
#fade_out(duration = 0.3, options = {}, &after) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/sugarcube/uiview.rb', line 15 def fade_out(duration=0.3, ={}, &after) UIView.animateWithDuration(duration, delay: [:delay] || 0, options: [:options] || UIViewAnimationOptionCurveLinear, animations: proc{ self.layer.opacity = [:opacity] || 0 }, completion:after ) end |
#move_to(position, duration = 0.3, options = {}, &after) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/sugarcube/uiview.rb', line 25 def move_to(position, duration=0.3, ={}, &after) UIView.animateWithDuration(duration, delay: [:delay] || 0, options: [:options] || UIViewAnimationOptionCurveLinear, animations: proc{ f = self.frame f.origin = position self.frame = position }, completion:after ) end |
#to_s ⇒ Object
9 10 11 12 13 |
# File 'lib/sugarcube/uiview.rb', line 9 def to_s "{#{self.class.name} @ x: #{self.frame.origin.x} y:#{self.frame.origin.y}, "\ "#{self.frame.size.width}×#{self.frame.size.height}}"\ "#{self.superview ? ' child of ' + self.superview.class.name : ''}" end |