Class: ImageViewWithOverlay

Inherits:
UIImageView
  • Object
show all
Defined in:
lib/motion-horizontal-scroll/image_view_with_overlay.rb

Constant Summary collapse

OVERLAY_VIEW_TAG =
100

Instance Method Summary collapse

Instance Method Details

#touchesBegan(touches, withEvent: event) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/motion-horizontal-scroll/image_view_with_overlay.rb', line 4

def touchesBegan(touches,withEvent: event)
  overlay = UIView.alloc.initWithFrame(self.bounds)
  overlay.tag = OVERLAY_VIEW_TAG
  overlay.alpha = 0.5
  overlay.backgroundColor = UIColor.blackColor
  self.addSubview(overlay)
  self.superview.touchesBegan(touches,withEvent: event)
end

#touchesCancelled(touches, withEvent: event) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/motion-horizontal-scroll/image_view_with_overlay.rb', line 25

def touchesCancelled(touches,withEvent: event)
  overlay = self.viewWithTag(OVERLAY_VIEW_TAG)
  unless overlay.nil? == true
    UIView.animateWithDuration(0.4, animations: lambda{
                                 overlay.alpha = 0
                               },completion: lambda{|done|
                                 overlay.removeFromSuperview
                               })
  end
  self.superview.touchesCancelled(touches,withEvent: event)
end

#touchesEnded(touches, withEvent: event) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/motion-horizontal-scroll/image_view_with_overlay.rb', line 13

def touchesEnded(touches,withEvent: event)
  overlay = self.viewWithTag(OVERLAY_VIEW_TAG)
  unless overlay.nil? == true
    UIView.animateWithDuration(0.4, animations: lambda{
                                 overlay.alpha = 0
                               },completion: lambda{|done|
                                 overlay.removeFromSuperview
                               })
  end
  self.superview.touchesEnded(touches,withEvent: event)
end