motion-grid-overlay 1.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +17 -15
- data/lib/project/views/grid_overlay_view.rb +16 -30
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2a8b3b22e3e408cbeda518456cfc10b00121bb5
|
4
|
+
data.tar.gz: 334260d7a8da2181dcff90cc525764e09b43777f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b7ee88137c158390c08368138463b23244a4b8104e060e77b488b74d7d1f47c1ea111f333c4b47f4b55b6fb80b85dba5a9ba8cff95a335d4b432e2cb1bfef10
|
7
|
+
data.tar.gz: a1dda19c168b7191dcbd5f24ef54479298a9c0a7cc5b8738f4b73093226db17a538adb501025a2ee798bc2e326b19b3a110812fab958ea9bff4084cd84ab7fe0
|
data/README.md
CHANGED
@@ -2,6 +2,23 @@
|
|
2
2
|
|
3
3
|
Simple grid overlay UIView subclass
|
4
4
|
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
``` ruby
|
8
|
+
grid_overlay = Motion::GridOverlayView.alloc.initWithFrame(target_view.bounds)
|
9
|
+
|
10
|
+
grid_overlay.x_lines = 3 # defaults to 2
|
11
|
+
grid_overlay.y_lines = 3 # defaults to 2
|
12
|
+
grid_overlay.stroke_color = UIColor.redColor # defaults to UIColor.grayColor
|
13
|
+
grid_overlay.stroke_width = 2.0 # defaults to 1.0
|
14
|
+
|
15
|
+
grid_overlay.hide
|
16
|
+
grid_overlay.show
|
17
|
+
grid_overlay.toggle
|
18
|
+
|
19
|
+
target_view.addSubview(grid_overlay)
|
20
|
+
```
|
21
|
+
|
5
22
|
## Setup
|
6
23
|
|
7
24
|
Add this line to your application's Gemfile:
|
@@ -16,21 +33,6 @@ Or install it yourself as:
|
|
16
33
|
|
17
34
|
$ gem install motion-grid-overlay
|
18
35
|
|
19
|
-
## Usage
|
20
|
-
|
21
|
-
grid_overlay = Motion::GridOverlayView.alloc.initWithFrame(target_view.bounds)
|
22
|
-
|
23
|
-
grid_overlay.x_lines = 3 # defaults to 2
|
24
|
-
grid_overlay.y_lines = 3 # defaults to 2
|
25
|
-
grid_overlay.stroke_color = UIColor.redColor # defaults to UIColor.grayColor
|
26
|
-
grid_overlay.stroke_width = 2.0 # defaults to 1.0
|
27
|
-
|
28
|
-
grid_overlay.hide
|
29
|
-
grid_overlay.show
|
30
|
-
grid_overlay.toggle
|
31
|
-
|
32
|
-
target_view.addSubview(grid_overlay)
|
33
|
-
|
34
36
|
## Contributing
|
35
37
|
|
36
38
|
1. Fork it
|
@@ -14,35 +14,17 @@ class Motion
|
|
14
14
|
|
15
15
|
self.x_lines = DEFAULTS[:x_lines]
|
16
16
|
self.y_lines = DEFAULTS[:y_lines]
|
17
|
-
|
18
|
-
|
17
|
+
@stroke_color = DEFAULTS[:stroke_color]
|
18
|
+
@stroke_width = DEFAULTS[:stroke_width]
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
def toggle
|
23
|
-
|
24
|
-
show
|
25
|
-
else
|
26
|
-
hide
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def show
|
31
|
-
self.stroke_color = @original_color
|
23
|
+
setHidden(!hidden?)
|
32
24
|
|
33
25
|
setNeedsDisplay
|
34
26
|
end
|
35
27
|
|
36
|
-
def hide
|
37
|
-
unless hidden?
|
38
|
-
@original_color = stroke_color
|
39
|
-
|
40
|
-
self.stroke_color = UIColor.clearColor
|
41
|
-
|
42
|
-
setNeedsDisplay
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
28
|
def x_lines=(lines)
|
47
29
|
@x_lines = lines
|
48
30
|
self.y_interval = frame.size.height / (lines + 1)
|
@@ -74,28 +56,32 @@ class Motion
|
|
74
56
|
|
75
57
|
setup_drawing
|
76
58
|
|
77
|
-
|
78
|
-
|
59
|
+
CGContextClearRect(context, bounds)
|
60
|
+
|
61
|
+
unless hidden?
|
62
|
+
draw_horizontal_lines
|
63
|
+
draw_vertical_lines
|
79
64
|
|
80
|
-
|
65
|
+
fill_path
|
66
|
+
end
|
81
67
|
end
|
82
68
|
|
83
69
|
private
|
84
70
|
|
85
|
-
def hidden?
|
86
|
-
stroke_color == UIColor.clearColor
|
87
|
-
end
|
88
|
-
|
89
71
|
def setup_drawing
|
90
|
-
CGContextSetStrokeColorWithColor(context, stroke_color.CGColor)
|
72
|
+
CGContextSetStrokeColorWithColor(context, stroke_color.colorWithAlphaComponent(0.5).CGColor)
|
91
73
|
|
92
74
|
CGContextSetLineWidth(context, stroke_width)
|
93
75
|
end
|
94
76
|
|
95
77
|
def draw_horizontal_lines
|
78
|
+
draw_line([0, 0], [size.width, 0])
|
79
|
+
|
96
80
|
(1..x_lines).each do |i|
|
97
81
|
draw_line([0, y_interval * i], [size.width, y_interval * i])
|
98
82
|
end
|
83
|
+
|
84
|
+
draw_line([0, size.height], [size.width, size.height])
|
99
85
|
end
|
100
86
|
|
101
87
|
def draw_vertical_lines
|
@@ -115,7 +101,7 @@ class Motion
|
|
115
101
|
end
|
116
102
|
|
117
103
|
def context
|
118
|
-
@
|
104
|
+
@context ||= UIGraphicsGetCurrentContext()
|
119
105
|
end
|
120
106
|
end
|
121
107
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: motion-grid-overlay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Devon Blandin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -54,7 +54,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
54
54
|
version: '0'
|
55
55
|
requirements: []
|
56
56
|
rubyforge_project:
|
57
|
-
rubygems_version: 2.
|
57
|
+
rubygems_version: 2.1.1
|
58
58
|
signing_key:
|
59
59
|
specification_version: 4
|
60
60
|
summary: Simple grid overlay UIView subclass
|