5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/motion-xray/views/xray_color_swatch.rb', line 5
def initWithFrame(frame)
super.tap do
gradient_view = XrayGradientView.alloc.initWithFrame(self.bounds).tap do |gradient_view|
gradient_view.layer.borderWidth = 1
gradient_view.layer.borderColor = :gray.uicolor.CGColor
gradient_view.userInteractionEnabled = false
end
self << gradient_view
swatch_rect = gradient_view.bounds.shrink(3)
gradient_view << XrayTriangleSwatch.alloc.initWithFrame(swatch_rect)
@color_swatch = UIView.alloc.initWithFrame(swatch_rect).tap do |color_swatch|
color_swatch.layer.borderWidth = 1
color_swatch.layer.borderColor = :dimgray.uicolor.CGColor
end
gradient_view << @color_swatch
@pressed_shader = UIView.alloc.initWithFrame(self.bounds).tap do |pressed_shader|
pressed_shader.backgroundColor = :black.uicolor(0.5)
pressed_shader.hide
end
self << @pressed_shader
self.on :touch_start do
@pressed_shader.show
end
self.on :touch_stop do
@pressed_shader.hide
end
end
end
|