├── .gitignore
├── .idea
├── .name
├── FDRotationGestureRecognizer.iml
├── encodings.xml
├── modules.xml
├── scopes
│ └── scope_settings.xml
├── vcs.xml
├── workspace.xml
└── xcode.xml
├── FDRotationGestureRecognizer.podspec
├── FDRotationGestureRecognizer.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ └── contents.xcworkspacedata
└── xcuserdata
│ └── frank.xcuserdatad
│ └── xcschemes
│ ├── All in FDRotationGestureRecognizerTests.m.xcscheme
│ ├── FDRotationGestureRecognizer.xcscheme
│ └── xcschememanagement.plist
├── FDRotationGestureRecognizer
├── AppDelegate.h
├── AppDelegate.m
├── Base.lproj
│ ├── LaunchScreen.xib
│ └── Main.storyboard
├── FDRotationGestureRecognizer
│ ├── FDRotationGestureRecognizer.h
│ └── FDRotationGestureRecognizer.m
├── Images.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
├── Info.plist
├── ViewController.h
├── ViewController.m
└── main.m
├── FDRotationGestureRecognizerTests
├── FDRotationGestureRecognizerTests.m
└── Info.plist
├── LICENSE
├── Other
├── demo.gif
├── demo.mov
├── explanation.png
└── myfert.jpeg
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | ignored/
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | FDRotationGestureRecognizer
--------------------------------------------------------------------------------
/.idea/FDRotationGestureRecognizer.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/scopes/scope_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/workspace.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
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 |
44 |
45 |
46 | true
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 | 1434906699068
179 |
180 | 1434906699068
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
--------------------------------------------------------------------------------
/.idea/xcode.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/FDRotationGestureRecognizer.podspec:
--------------------------------------------------------------------------------
1 | Pod::Spec.new do |s|
2 |
3 | s.name = "FDRotationGestureRecognizer"
4 | s.version = "0.0.1"
5 | s.summary = "A gesture recognizer for rotations"
6 |
7 | s.description = <<-DESC
8 | A UIGestureRecognizer subclass that, once added to a view, allows to easily measure the rotation performed by the user dragging on the screen.
9 | DESC
10 |
11 | s.homepage = "https://github.com/frankdilo/FDRotationGestureRecognizer"
12 | s.screenshots = "https://raw.githubusercontent.com/frankdilo/FDRotationGestureRecognizer/master/Other/demo.gif", "https://raw.githubusercontent.com/frankdilo/FDRotationGestureRecognizer/master/Other/explanation.png", "https://raw.githubusercontent.com/frankdilo/FDRotationGestureRecognizer/master/Other/myfert.jpeg"
13 |
14 | s.platform = :ios, '8.0'
15 |
16 | s.license = "MIT"
17 |
18 | s.author = { "Francesco Di Lorenzo" => "francescodilorenzo@me.com" }
19 | s.social_media_url = "http://twitter.com/frankdilo"
20 |
21 | s.source = { :git => "https://github.com/frankdilo/FDRotationGestureRecognizer.git", :tag => "0.0.1" }
22 |
23 | s.source_files = "Classes", "FDRotationGestureRecognizer/FDRotationGestureRecognizer/*.{h,m}"
24 |
25 | s.frameworks = 'UIKit'
26 |
27 | end
28 |
--------------------------------------------------------------------------------
/FDRotationGestureRecognizer.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 01DCBDFA1B37214A00EC7B02 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 01DCBDF91B37214A00EC7B02 /* main.m */; };
11 | 01DCBDFD1B37214A00EC7B02 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 01DCBDFC1B37214A00EC7B02 /* AppDelegate.m */; };
12 | 01DCBE001B37214A00EC7B02 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 01DCBDFF1B37214A00EC7B02 /* ViewController.m */; };
13 | 01DCBE031B37214A00EC7B02 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 01DCBE011B37214A00EC7B02 /* Main.storyboard */; };
14 | 01DCBE051B37214A00EC7B02 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 01DCBE041B37214A00EC7B02 /* Images.xcassets */; };
15 | 01DCBE081B37214A00EC7B02 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 01DCBE061B37214A00EC7B02 /* LaunchScreen.xib */; };
16 | 01DCBE141B37214B00EC7B02 /* FDRotationGestureRecognizerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 01DCBE131B37214B00EC7B02 /* FDRotationGestureRecognizerTests.m */; };
17 | 5D2A976A970A42D5F609455D /* FDRotationGestureRecognizer.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D2A9088F5F81337BFDF445E /* FDRotationGestureRecognizer.m */; };
18 | 5D2A9BA382528B5725D337C9 /* FDRotationGestureRecognizer.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D2A9088F5F81337BFDF445E /* FDRotationGestureRecognizer.m */; };
19 | /* End PBXBuildFile section */
20 |
21 | /* Begin PBXContainerItemProxy section */
22 | 01DCBE0E1B37214B00EC7B02 /* PBXContainerItemProxy */ = {
23 | isa = PBXContainerItemProxy;
24 | containerPortal = 01DCBDEC1B37214A00EC7B02 /* Project object */;
25 | proxyType = 1;
26 | remoteGlobalIDString = 01DCBDF31B37214A00EC7B02;
27 | remoteInfo = FDRotationGestureRecognizer;
28 | };
29 | /* End PBXContainerItemProxy section */
30 |
31 | /* Begin PBXFileReference section */
32 | 01DCBDF41B37214A00EC7B02 /* FDRotationGestureRecognizer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FDRotationGestureRecognizer.app; sourceTree = BUILT_PRODUCTS_DIR; };
33 | 01DCBDF81B37214A00EC7B02 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
34 | 01DCBDF91B37214A00EC7B02 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
35 | 01DCBDFB1B37214A00EC7B02 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
36 | 01DCBDFC1B37214A00EC7B02 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
37 | 01DCBDFE1B37214A00EC7B02 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; };
38 | 01DCBDFF1B37214A00EC7B02 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; };
39 | 01DCBE021B37214A00EC7B02 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
40 | 01DCBE041B37214A00EC7B02 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; };
41 | 01DCBE071B37214A00EC7B02 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; };
42 | 01DCBE0D1B37214B00EC7B02 /* FDRotationGestureRecognizerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = FDRotationGestureRecognizerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
43 | 01DCBE121B37214B00EC7B02 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
44 | 01DCBE131B37214B00EC7B02 /* FDRotationGestureRecognizerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FDRotationGestureRecognizerTests.m; sourceTree = ""; };
45 | 5D2A9088F5F81337BFDF445E /* FDRotationGestureRecognizer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FDRotationGestureRecognizer.m; sourceTree = ""; };
46 | 5D2A926C4424F07D819E17F3 /* FDRotationGestureRecognizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FDRotationGestureRecognizer.h; sourceTree = ""; };
47 | /* End PBXFileReference section */
48 |
49 | /* Begin PBXFrameworksBuildPhase section */
50 | 01DCBDF11B37214A00EC7B02 /* Frameworks */ = {
51 | isa = PBXFrameworksBuildPhase;
52 | buildActionMask = 2147483647;
53 | files = (
54 | );
55 | runOnlyForDeploymentPostprocessing = 0;
56 | };
57 | 01DCBE0A1B37214B00EC7B02 /* Frameworks */ = {
58 | isa = PBXFrameworksBuildPhase;
59 | buildActionMask = 2147483647;
60 | files = (
61 | );
62 | runOnlyForDeploymentPostprocessing = 0;
63 | };
64 | /* End PBXFrameworksBuildPhase section */
65 |
66 | /* Begin PBXGroup section */
67 | 01DCBDEB1B37214A00EC7B02 = {
68 | isa = PBXGroup;
69 | children = (
70 | 01DCBDF61B37214A00EC7B02 /* FDRotationGestureRecognizer */,
71 | 01DCBE101B37214B00EC7B02 /* FDRotationGestureRecognizerTests */,
72 | 01DCBDF51B37214A00EC7B02 /* Products */,
73 | );
74 | sourceTree = "";
75 | };
76 | 01DCBDF51B37214A00EC7B02 /* Products */ = {
77 | isa = PBXGroup;
78 | children = (
79 | 01DCBDF41B37214A00EC7B02 /* FDRotationGestureRecognizer.app */,
80 | 01DCBE0D1B37214B00EC7B02 /* FDRotationGestureRecognizerTests.xctest */,
81 | );
82 | name = Products;
83 | sourceTree = "";
84 | };
85 | 01DCBDF61B37214A00EC7B02 /* FDRotationGestureRecognizer */ = {
86 | isa = PBXGroup;
87 | children = (
88 | 01DCBE1D1B37225C00EC7B02 /* FDRotationGestureRecognizer */,
89 | 01DCBDFB1B37214A00EC7B02 /* AppDelegate.h */,
90 | 01DCBDFC1B37214A00EC7B02 /* AppDelegate.m */,
91 | 01DCBDFE1B37214A00EC7B02 /* ViewController.h */,
92 | 01DCBDFF1B37214A00EC7B02 /* ViewController.m */,
93 | 01DCBE011B37214A00EC7B02 /* Main.storyboard */,
94 | 01DCBE041B37214A00EC7B02 /* Images.xcassets */,
95 | 01DCBE061B37214A00EC7B02 /* LaunchScreen.xib */,
96 | 01DCBDF71B37214A00EC7B02 /* Supporting Files */,
97 | );
98 | path = FDRotationGestureRecognizer;
99 | sourceTree = "";
100 | };
101 | 01DCBDF71B37214A00EC7B02 /* Supporting Files */ = {
102 | isa = PBXGroup;
103 | children = (
104 | 01DCBDF81B37214A00EC7B02 /* Info.plist */,
105 | 01DCBDF91B37214A00EC7B02 /* main.m */,
106 | );
107 | name = "Supporting Files";
108 | sourceTree = "";
109 | };
110 | 01DCBE101B37214B00EC7B02 /* FDRotationGestureRecognizerTests */ = {
111 | isa = PBXGroup;
112 | children = (
113 | 01DCBE131B37214B00EC7B02 /* FDRotationGestureRecognizerTests.m */,
114 | 01DCBE111B37214B00EC7B02 /* Supporting Files */,
115 | );
116 | path = FDRotationGestureRecognizerTests;
117 | sourceTree = "";
118 | };
119 | 01DCBE111B37214B00EC7B02 /* Supporting Files */ = {
120 | isa = PBXGroup;
121 | children = (
122 | 01DCBE121B37214B00EC7B02 /* Info.plist */,
123 | );
124 | name = "Supporting Files";
125 | sourceTree = "";
126 | };
127 | 01DCBE1D1B37225C00EC7B02 /* FDRotationGestureRecognizer */ = {
128 | isa = PBXGroup;
129 | children = (
130 | 5D2A926C4424F07D819E17F3 /* FDRotationGestureRecognizer.h */,
131 | 5D2A9088F5F81337BFDF445E /* FDRotationGestureRecognizer.m */,
132 | );
133 | path = FDRotationGestureRecognizer;
134 | sourceTree = "";
135 | };
136 | /* End PBXGroup section */
137 |
138 | /* Begin PBXNativeTarget section */
139 | 01DCBDF31B37214A00EC7B02 /* FDRotationGestureRecognizer */ = {
140 | isa = PBXNativeTarget;
141 | buildConfigurationList = 01DCBE171B37214B00EC7B02 /* Build configuration list for PBXNativeTarget "FDRotationGestureRecognizer" */;
142 | buildPhases = (
143 | 01DCBDF01B37214A00EC7B02 /* Sources */,
144 | 01DCBDF11B37214A00EC7B02 /* Frameworks */,
145 | 01DCBDF21B37214A00EC7B02 /* Resources */,
146 | );
147 | buildRules = (
148 | );
149 | dependencies = (
150 | );
151 | name = FDRotationGestureRecognizer;
152 | productName = FDRotationGestureRecognizer;
153 | productReference = 01DCBDF41B37214A00EC7B02 /* FDRotationGestureRecognizer.app */;
154 | productType = "com.apple.product-type.application";
155 | };
156 | 01DCBE0C1B37214B00EC7B02 /* FDRotationGestureRecognizerTests */ = {
157 | isa = PBXNativeTarget;
158 | buildConfigurationList = 01DCBE1A1B37214B00EC7B02 /* Build configuration list for PBXNativeTarget "FDRotationGestureRecognizerTests" */;
159 | buildPhases = (
160 | 01DCBE091B37214B00EC7B02 /* Sources */,
161 | 01DCBE0A1B37214B00EC7B02 /* Frameworks */,
162 | 01DCBE0B1B37214B00EC7B02 /* Resources */,
163 | );
164 | buildRules = (
165 | );
166 | dependencies = (
167 | 01DCBE0F1B37214B00EC7B02 /* PBXTargetDependency */,
168 | );
169 | name = FDRotationGestureRecognizerTests;
170 | productName = FDRotationGestureRecognizerTests;
171 | productReference = 01DCBE0D1B37214B00EC7B02 /* FDRotationGestureRecognizerTests.xctest */;
172 | productType = "com.apple.product-type.bundle.unit-test";
173 | };
174 | /* End PBXNativeTarget section */
175 |
176 | /* Begin PBXProject section */
177 | 01DCBDEC1B37214A00EC7B02 /* Project object */ = {
178 | isa = PBXProject;
179 | attributes = {
180 | LastUpgradeCheck = 0630;
181 | ORGANIZATIONNAME = "Francesco Di Lorenzo";
182 | TargetAttributes = {
183 | 01DCBDF31B37214A00EC7B02 = {
184 | CreatedOnToolsVersion = 6.3.2;
185 | };
186 | 01DCBE0C1B37214B00EC7B02 = {
187 | CreatedOnToolsVersion = 6.3.2;
188 | TestTargetID = 01DCBDF31B37214A00EC7B02;
189 | };
190 | };
191 | };
192 | buildConfigurationList = 01DCBDEF1B37214A00EC7B02 /* Build configuration list for PBXProject "FDRotationGestureRecognizer" */;
193 | compatibilityVersion = "Xcode 3.2";
194 | developmentRegion = English;
195 | hasScannedForEncodings = 0;
196 | knownRegions = (
197 | en,
198 | Base,
199 | );
200 | mainGroup = 01DCBDEB1B37214A00EC7B02;
201 | productRefGroup = 01DCBDF51B37214A00EC7B02 /* Products */;
202 | projectDirPath = "";
203 | projectRoot = "";
204 | targets = (
205 | 01DCBDF31B37214A00EC7B02 /* FDRotationGestureRecognizer */,
206 | 01DCBE0C1B37214B00EC7B02 /* FDRotationGestureRecognizerTests */,
207 | );
208 | };
209 | /* End PBXProject section */
210 |
211 | /* Begin PBXResourcesBuildPhase section */
212 | 01DCBDF21B37214A00EC7B02 /* Resources */ = {
213 | isa = PBXResourcesBuildPhase;
214 | buildActionMask = 2147483647;
215 | files = (
216 | 01DCBE031B37214A00EC7B02 /* Main.storyboard in Resources */,
217 | 01DCBE081B37214A00EC7B02 /* LaunchScreen.xib in Resources */,
218 | 01DCBE051B37214A00EC7B02 /* Images.xcassets in Resources */,
219 | );
220 | runOnlyForDeploymentPostprocessing = 0;
221 | };
222 | 01DCBE0B1B37214B00EC7B02 /* Resources */ = {
223 | isa = PBXResourcesBuildPhase;
224 | buildActionMask = 2147483647;
225 | files = (
226 | );
227 | runOnlyForDeploymentPostprocessing = 0;
228 | };
229 | /* End PBXResourcesBuildPhase section */
230 |
231 | /* Begin PBXSourcesBuildPhase section */
232 | 01DCBDF01B37214A00EC7B02 /* Sources */ = {
233 | isa = PBXSourcesBuildPhase;
234 | buildActionMask = 2147483647;
235 | files = (
236 | 01DCBE001B37214A00EC7B02 /* ViewController.m in Sources */,
237 | 01DCBDFD1B37214A00EC7B02 /* AppDelegate.m in Sources */,
238 | 01DCBDFA1B37214A00EC7B02 /* main.m in Sources */,
239 | 5D2A9BA382528B5725D337C9 /* FDRotationGestureRecognizer.m in Sources */,
240 | );
241 | runOnlyForDeploymentPostprocessing = 0;
242 | };
243 | 01DCBE091B37214B00EC7B02 /* Sources */ = {
244 | isa = PBXSourcesBuildPhase;
245 | buildActionMask = 2147483647;
246 | files = (
247 | 01DCBE141B37214B00EC7B02 /* FDRotationGestureRecognizerTests.m in Sources */,
248 | 5D2A976A970A42D5F609455D /* FDRotationGestureRecognizer.m in Sources */,
249 | );
250 | runOnlyForDeploymentPostprocessing = 0;
251 | };
252 | /* End PBXSourcesBuildPhase section */
253 |
254 | /* Begin PBXTargetDependency section */
255 | 01DCBE0F1B37214B00EC7B02 /* PBXTargetDependency */ = {
256 | isa = PBXTargetDependency;
257 | target = 01DCBDF31B37214A00EC7B02 /* FDRotationGestureRecognizer */;
258 | targetProxy = 01DCBE0E1B37214B00EC7B02 /* PBXContainerItemProxy */;
259 | };
260 | /* End PBXTargetDependency section */
261 |
262 | /* Begin PBXVariantGroup section */
263 | 01DCBE011B37214A00EC7B02 /* Main.storyboard */ = {
264 | isa = PBXVariantGroup;
265 | children = (
266 | 01DCBE021B37214A00EC7B02 /* Base */,
267 | );
268 | name = Main.storyboard;
269 | sourceTree = "";
270 | };
271 | 01DCBE061B37214A00EC7B02 /* LaunchScreen.xib */ = {
272 | isa = PBXVariantGroup;
273 | children = (
274 | 01DCBE071B37214A00EC7B02 /* Base */,
275 | );
276 | name = LaunchScreen.xib;
277 | sourceTree = "";
278 | };
279 | /* End PBXVariantGroup section */
280 |
281 | /* Begin XCBuildConfiguration section */
282 | 01DCBE151B37214B00EC7B02 /* Debug */ = {
283 | isa = XCBuildConfiguration;
284 | buildSettings = {
285 | ALWAYS_SEARCH_USER_PATHS = NO;
286 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
287 | CLANG_CXX_LIBRARY = "libc++";
288 | CLANG_ENABLE_MODULES = YES;
289 | CLANG_ENABLE_OBJC_ARC = YES;
290 | CLANG_WARN_BOOL_CONVERSION = YES;
291 | CLANG_WARN_CONSTANT_CONVERSION = YES;
292 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
293 | CLANG_WARN_EMPTY_BODY = YES;
294 | CLANG_WARN_ENUM_CONVERSION = YES;
295 | CLANG_WARN_INT_CONVERSION = YES;
296 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
297 | CLANG_WARN_UNREACHABLE_CODE = YES;
298 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
299 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
300 | COPY_PHASE_STRIP = NO;
301 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
302 | ENABLE_STRICT_OBJC_MSGSEND = YES;
303 | GCC_C_LANGUAGE_STANDARD = gnu99;
304 | GCC_DYNAMIC_NO_PIC = NO;
305 | GCC_NO_COMMON_BLOCKS = YES;
306 | GCC_OPTIMIZATION_LEVEL = 0;
307 | GCC_PREPROCESSOR_DEFINITIONS = (
308 | "DEBUG=1",
309 | "$(inherited)",
310 | );
311 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
312 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
313 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
314 | GCC_WARN_UNDECLARED_SELECTOR = YES;
315 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
316 | GCC_WARN_UNUSED_FUNCTION = YES;
317 | GCC_WARN_UNUSED_VARIABLE = YES;
318 | IPHONEOS_DEPLOYMENT_TARGET = 8.3;
319 | MTL_ENABLE_DEBUG_INFO = YES;
320 | ONLY_ACTIVE_ARCH = YES;
321 | SDKROOT = iphoneos;
322 | TARGETED_DEVICE_FAMILY = "1,2";
323 | };
324 | name = Debug;
325 | };
326 | 01DCBE161B37214B00EC7B02 /* Release */ = {
327 | isa = XCBuildConfiguration;
328 | buildSettings = {
329 | ALWAYS_SEARCH_USER_PATHS = NO;
330 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
331 | CLANG_CXX_LIBRARY = "libc++";
332 | CLANG_ENABLE_MODULES = YES;
333 | CLANG_ENABLE_OBJC_ARC = YES;
334 | CLANG_WARN_BOOL_CONVERSION = YES;
335 | CLANG_WARN_CONSTANT_CONVERSION = YES;
336 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
337 | CLANG_WARN_EMPTY_BODY = YES;
338 | CLANG_WARN_ENUM_CONVERSION = YES;
339 | CLANG_WARN_INT_CONVERSION = YES;
340 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
341 | CLANG_WARN_UNREACHABLE_CODE = YES;
342 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
343 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
344 | COPY_PHASE_STRIP = NO;
345 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
346 | ENABLE_NS_ASSERTIONS = NO;
347 | ENABLE_STRICT_OBJC_MSGSEND = YES;
348 | GCC_C_LANGUAGE_STANDARD = gnu99;
349 | GCC_NO_COMMON_BLOCKS = YES;
350 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
351 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
352 | GCC_WARN_UNDECLARED_SELECTOR = YES;
353 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
354 | GCC_WARN_UNUSED_FUNCTION = YES;
355 | GCC_WARN_UNUSED_VARIABLE = YES;
356 | IPHONEOS_DEPLOYMENT_TARGET = 8.3;
357 | MTL_ENABLE_DEBUG_INFO = NO;
358 | SDKROOT = iphoneos;
359 | TARGETED_DEVICE_FAMILY = "1,2";
360 | VALIDATE_PRODUCT = YES;
361 | };
362 | name = Release;
363 | };
364 | 01DCBE181B37214B00EC7B02 /* Debug */ = {
365 | isa = XCBuildConfiguration;
366 | buildSettings = {
367 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
368 | INFOPLIST_FILE = FDRotationGestureRecognizer/Info.plist;
369 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
370 | PRODUCT_NAME = "$(TARGET_NAME)";
371 | };
372 | name = Debug;
373 | };
374 | 01DCBE191B37214B00EC7B02 /* Release */ = {
375 | isa = XCBuildConfiguration;
376 | buildSettings = {
377 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
378 | INFOPLIST_FILE = FDRotationGestureRecognizer/Info.plist;
379 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
380 | PRODUCT_NAME = "$(TARGET_NAME)";
381 | };
382 | name = Release;
383 | };
384 | 01DCBE1B1B37214B00EC7B02 /* Debug */ = {
385 | isa = XCBuildConfiguration;
386 | buildSettings = {
387 | BUNDLE_LOADER = "$(TEST_HOST)";
388 | FRAMEWORK_SEARCH_PATHS = (
389 | "$(SDKROOT)/Developer/Library/Frameworks",
390 | "$(inherited)",
391 | );
392 | GCC_PREPROCESSOR_DEFINITIONS = (
393 | "DEBUG=1",
394 | "$(inherited)",
395 | );
396 | INFOPLIST_FILE = FDRotationGestureRecognizerTests/Info.plist;
397 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
398 | PRODUCT_NAME = "$(TARGET_NAME)";
399 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FDRotationGestureRecognizer.app/FDRotationGestureRecognizer";
400 | };
401 | name = Debug;
402 | };
403 | 01DCBE1C1B37214B00EC7B02 /* Release */ = {
404 | isa = XCBuildConfiguration;
405 | buildSettings = {
406 | BUNDLE_LOADER = "$(TEST_HOST)";
407 | FRAMEWORK_SEARCH_PATHS = (
408 | "$(SDKROOT)/Developer/Library/Frameworks",
409 | "$(inherited)",
410 | );
411 | INFOPLIST_FILE = FDRotationGestureRecognizerTests/Info.plist;
412 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
413 | PRODUCT_NAME = "$(TARGET_NAME)";
414 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FDRotationGestureRecognizer.app/FDRotationGestureRecognizer";
415 | };
416 | name = Release;
417 | };
418 | /* End XCBuildConfiguration section */
419 |
420 | /* Begin XCConfigurationList section */
421 | 01DCBDEF1B37214A00EC7B02 /* Build configuration list for PBXProject "FDRotationGestureRecognizer" */ = {
422 | isa = XCConfigurationList;
423 | buildConfigurations = (
424 | 01DCBE151B37214B00EC7B02 /* Debug */,
425 | 01DCBE161B37214B00EC7B02 /* Release */,
426 | );
427 | defaultConfigurationIsVisible = 0;
428 | defaultConfigurationName = Release;
429 | };
430 | 01DCBE171B37214B00EC7B02 /* Build configuration list for PBXNativeTarget "FDRotationGestureRecognizer" */ = {
431 | isa = XCConfigurationList;
432 | buildConfigurations = (
433 | 01DCBE181B37214B00EC7B02 /* Debug */,
434 | 01DCBE191B37214B00EC7B02 /* Release */,
435 | );
436 | defaultConfigurationIsVisible = 0;
437 | defaultConfigurationName = Release;
438 | };
439 | 01DCBE1A1B37214B00EC7B02 /* Build configuration list for PBXNativeTarget "FDRotationGestureRecognizerTests" */ = {
440 | isa = XCConfigurationList;
441 | buildConfigurations = (
442 | 01DCBE1B1B37214B00EC7B02 /* Debug */,
443 | 01DCBE1C1B37214B00EC7B02 /* Release */,
444 | );
445 | defaultConfigurationIsVisible = 0;
446 | defaultConfigurationName = Release;
447 | };
448 | /* End XCConfigurationList section */
449 | };
450 | rootObject = 01DCBDEC1B37214A00EC7B02 /* Project object */;
451 | }
452 |
--------------------------------------------------------------------------------
/FDRotationGestureRecognizer.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/FDRotationGestureRecognizer.xcodeproj/xcuserdata/frank.xcuserdatad/xcschemes/All in FDRotationGestureRecognizerTests.m.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
9 |
15 |
16 |
17 |
18 |
19 |
21 |
22 |
23 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/FDRotationGestureRecognizer.xcodeproj/xcuserdata/frank.xcuserdatad/xcschemes/FDRotationGestureRecognizer.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
29 |
35 |
36 |
37 |
38 |
39 |
44 |
45 |
47 |
53 |
54 |
55 |
56 |
57 |
63 |
64 |
65 |
66 |
75 |
77 |
83 |
84 |
85 |
86 |
87 |
88 |
94 |
96 |
102 |
103 |
104 |
105 |
107 |
108 |
111 |
112 |
113 |
--------------------------------------------------------------------------------
/FDRotationGestureRecognizer.xcodeproj/xcuserdata/frank.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | FDRotationGestureRecognizer.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 01DCBDF31B37214A00EC7B02
16 |
17 | primary
18 |
19 |
20 | 01DCBE0C1B37214B00EC7B02
21 |
22 | primary
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/FDRotationGestureRecognizer/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // FDRotationGestureRecognizer
4 | //
5 | // Created by Francesco Di Lorenzo on 21/06/15.
6 | // Copyright (c) 2015 Francesco Di Lorenzo. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/FDRotationGestureRecognizer/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // FDRotationGestureRecognizer
4 | //
5 | // Created by Francesco Di Lorenzo on 21/06/15.
6 | // Copyright (c) 2015 Francesco Di Lorenzo. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 |
18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
19 | // Override point for customization after application launch.
20 | return YES;
21 | }
22 |
23 | - (void)applicationWillResignActive:(UIApplication *)application {
24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
26 | }
27 |
28 | - (void)applicationDidEnterBackground:(UIApplication *)application {
29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
31 | }
32 |
33 | - (void)applicationWillEnterForeground:(UIApplication *)application {
34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
35 | }
36 |
37 | - (void)applicationDidBecomeActive:(UIApplication *)application {
38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
39 | }
40 |
41 | - (void)applicationWillTerminate:(UIApplication *)application {
42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
43 | }
44 |
45 | @end
46 |
--------------------------------------------------------------------------------
/FDRotationGestureRecognizer/Base.lproj/LaunchScreen.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
20 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/FDRotationGestureRecognizer/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/FDRotationGestureRecognizer/FDRotationGestureRecognizer/FDRotationGestureRecognizer.h:
--------------------------------------------------------------------------------
1 | //
2 | // FDRotationGestureRecognizer.h
3 | //
4 | // Created by Francesco Di Lorenzo on 18/02/14.
5 | //
6 |
7 | #import
8 |
9 | @interface FDRotationGestureRecognizer : UIGestureRecognizer
10 |
11 | /**
12 | * Instantiate a gesture recognizer with the given center. When the interaction starts and the user starts dragging
13 | * on the view, the rotation is calculated relatively to the center.
14 | */
15 | - (instancetype)initWithCenter:(CGPoint)center;
16 |
17 | /**
18 | * The current rotation.
19 | */
20 | - (CGFloat)rotation;
21 |
22 |
23 | /**
24 | * Reset the rotation back to zero.
25 | */
26 | - (void)resetRotation;
27 |
28 | @end
29 |
--------------------------------------------------------------------------------
/FDRotationGestureRecognizer/FDRotationGestureRecognizer/FDRotationGestureRecognizer.m:
--------------------------------------------------------------------------------
1 | //
2 | // FDRotationGestureRecognizer.m
3 | //
4 | // Created by Francesco Di Lorenzo on 18/02/14.
5 | // Copyright (c) 2014 Francesco Di Lorenzo. All rights reserved.
6 | //
7 |
8 | #import "FDRotationGestureRecognizer.h"
9 | #import
10 |
11 | @interface FDRotationGestureRecognizer ()
12 |
13 | @property (nonatomic) CGFloat currentRotation;
14 | @property(nonatomic) CGPoint startingPoint;
15 | @property(nonatomic) CGPoint endPoint;
16 | @property(nonatomic) CGPoint center;
17 | @property(nonatomic) CGFloat previousRotation;
18 |
19 | @end
20 |
21 | @implementation FDRotationGestureRecognizer
22 |
23 | - (id) initWithCenter:(CGPoint)center
24 | {
25 | self = [super init];
26 | if (self) {
27 | self.center = center;
28 | self.currentRotation = 0;
29 | self.previousRotation = 0;
30 | self.startingPoint = CGPointZero;
31 | self.endPoint = CGPointZero;
32 | }
33 | return self;
34 | }
35 |
36 | - (CGFloat)rotation {
37 | return self.currentRotation + self.previousRotation;
38 | }
39 |
40 | - (void)resetRotation {
41 | self.currentRotation = 0;
42 | self.previousRotation = 0;
43 | }
44 |
45 |
46 | // Mirror of the touch-delivery methods on UIResponder
47 | // UIGestureRecognizers aren't in the responder chain, but observe touches hit-tested to their view and their view's subviews
48 | // UIGestureRecognizers receive touches before the view to which the touch was hit-tested
49 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
50 | {
51 | [super touchesBegan:touches withEvent:event];
52 |
53 | self.startingPoint = [[touches anyObject] locationInView:self.view];
54 | self.state = UIGestureRecognizerStateBegan;
55 | }
56 |
57 | - (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
58 | {
59 | [super touchesMoved:touches withEvent:event];
60 |
61 | CGPoint point = [[touches anyObject] locationInView:self.view];
62 | self.currentRotation = [self angleBetweenPoint:self.startingPoint andPoint:point];
63 | self.state = UIGestureRecognizerStateChanged;
64 | }
65 |
66 | - (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
67 | {
68 | [super touchesEnded:touches withEvent:event];
69 |
70 | self.endPoint = [[touches anyObject] locationInView:self.view];
71 | self.currentRotation = [self angleBetweenPoint:self.startingPoint andPoint:self.endPoint];
72 | self.state = UIGestureRecognizerStateEnded;
73 | }
74 |
75 | - (void) touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
76 | {
77 | [super touchesCancelled:touches withEvent:event];
78 | self.state = UIGestureRecognizerStateCancelled;
79 | }
80 |
81 | /**
82 | * Called automatically by the runtime after the gesture state has been set to UIGestureRecognizerStateEnded
83 | * any internal state should be reset to prepare for a new attempt to recognize the gesture after this is received all
84 | * remaining active touches will be ignored (no further updates will be received for touches that had already begun but
85 | * haven't ended)
86 | */
87 | - (void)reset
88 | {
89 | [super reset];
90 | _previousRotation = [self rotation];
91 | _currentRotation = 0;
92 | }
93 |
94 | #define rad_to_degree(x) (180*x)/M_PI
95 |
96 | - (CGFloat)angleBetweenPoint:(CGPoint)first andPoint:(CGPoint)second {
97 | CGPoint centeredPoint1 = CGPointMake(first.x - _center.x, first.y - _center.y);
98 | CGPoint centeredPoint2 = CGPointMake(second.x - _center.x, second.y - _center.y);
99 |
100 | CGFloat firstAngle = angleBetweenOriginAndPoint(centeredPoint1);
101 | CGFloat secondAngle = angleBetweenOriginAndPoint(centeredPoint2);
102 |
103 | CGFloat rads = secondAngle - firstAngle;
104 |
105 | return rads;
106 | }
107 |
108 | CGFloat angleBetweenOriginAndPoint(CGPoint p) {
109 | if (p.x == 0) {
110 | return sign(p.y) * M_PI;
111 | }
112 |
113 |
114 | CGFloat angle = atan(-p.y / p.x); // '-' because negative ordinates are positive in UIKit
115 |
116 | // atan() is defined in [-pi/2, pi/2], but we want a value in [0, 2*pi]
117 | // so we deal with these special cases accordingly
118 | switch (quadrantForPoint(p)) {
119 | case 1:
120 | case 2: angle += M_PI; break;
121 | case 3: angle += 2* M_PI; break;
122 | }
123 |
124 | return angle;
125 | }
126 |
127 | /**
128 | * Return the quadrants the given points belong to
129 | */
130 | NSInteger quadrantForPoint(CGPoint p) {
131 | if (p.x > 0 && p.y < 0) {
132 | return 0;
133 | } else if (p.x < 0 && p.y < 0) {
134 | return 1;
135 | } else if (p.x < 0 && p.y > 0) {
136 | return 2;
137 | } else if (p.x > 0 && p.y > 0) {
138 | return 3;
139 | }
140 |
141 | return 0;
142 | }
143 |
144 | NSInteger sign(CGFloat num) {
145 | if (num == 0) {
146 | return 0;
147 | } else if (num > 0) {
148 | return 1;
149 | } else {
150 | return -1;
151 | }
152 | }
153 |
154 | - (NSString *)description {
155 | NSMutableString *desc = [NSMutableString string];
156 | [desc appendFormat:@"\nangle: %f\n", self.currentRotation *180 / M_PI];
157 | return desc;
158 | }
159 |
160 | @end
161 |
--------------------------------------------------------------------------------
/FDRotationGestureRecognizer/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "ipad",
35 | "size" : "29x29",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "ipad",
40 | "size" : "29x29",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "40x40",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "40x40",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "76x76",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "76x76",
61 | "scale" : "2x"
62 | }
63 | ],
64 | "info" : {
65 | "version" : 1,
66 | "author" : "xcode"
67 | }
68 | }
--------------------------------------------------------------------------------
/FDRotationGestureRecognizer/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | com.francescodilorenzo.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 | UISupportedInterfaceOrientations~ipad
40 |
41 | UIInterfaceOrientationPortrait
42 | UIInterfaceOrientationPortraitUpsideDown
43 | UIInterfaceOrientationLandscapeLeft
44 | UIInterfaceOrientationLandscapeRight
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/FDRotationGestureRecognizer/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // FDRotationGestureRecognizer
4 | //
5 | // Created by Francesco Di Lorenzo on 21/06/15.
6 | // Copyright (c) 2015 Francesco Di Lorenzo. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class AngleView;
12 |
13 | @interface ViewController : UIViewController
14 |
15 | @property(nonatomic, strong) UIView *redSquare;
16 |
17 | @end
18 |
19 |
--------------------------------------------------------------------------------
/FDRotationGestureRecognizer/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // FDRotationGestureRecognizer
4 | //
5 | // Created by Francesco Di Lorenzo on 21/06/15.
6 | // Copyright (c) 2015 Francesco Di Lorenzo. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import "FDRotationGestureRecognizer.h"
11 |
12 | @interface ViewController ()
13 |
14 | @end
15 |
16 | @implementation ViewController
17 |
18 | - (void)viewDidLoad {
19 | [super viewDidLoad];
20 |
21 | self.redSquare = [[UIView alloc] initWithFrame:CGRectMake(self.view.center.x-50, self.view.center.y-50, 100, 100)];
22 | self.redSquare.backgroundColor = [UIColor redColor];
23 |
24 | [self.view addSubview:self.redSquare];
25 |
26 | FDRotationGestureRecognizer *gr = [[FDRotationGestureRecognizer alloc] initWithCenter:self.view.center];
27 | [gr addTarget:self action:@selector(rotationPerformed:)];
28 | [self.view addGestureRecognizer:gr];
29 | }
30 |
31 | - (void)rotationPerformed:(FDRotationGestureRecognizer *)gestureRec {
32 | self.redSquare.transform = CGAffineTransformMakeRotation(-[gestureRec rotation]);
33 | }
34 |
35 |
36 | @end
37 |
--------------------------------------------------------------------------------
/FDRotationGestureRecognizer/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // FDRotationGestureRecognizer
4 | //
5 | // Created by Francesco Di Lorenzo on 21/06/15.
6 | // Copyright (c) 2015 Francesco Di Lorenzo. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/FDRotationGestureRecognizerTests/FDRotationGestureRecognizerTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // FDRotationGestureRecognizerTests.m
3 | // FDRotationGestureRecognizerTests
4 | //
5 | // Created by Francesco Di Lorenzo on 21/06/15.
6 | // Copyright (c) 2015 Francesco Di Lorenzo. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | #import "FDRotationGestureRecognizer.h"
12 |
13 | @interface FDRotationGestureRecognizer (Testing)
14 |
15 | - (CGFloat)angleBetweenPoint:(CGPoint)first andPoint:(CGPoint)second;
16 |
17 | @end
18 |
19 | @interface FDRotationGestureRecognizerTests : XCTestCase
20 |
21 | @property FDRotationGestureRecognizer *gr;
22 |
23 | @end
24 |
25 | @implementation FDRotationGestureRecognizerTests
26 |
27 | #define DEGREE_TO_RAD(x) (x * M_PI)/180
28 |
29 | - (void)setUp {
30 | [super setUp];
31 |
32 | _gr = [[FDRotationGestureRecognizer alloc] initWithCenter:CGPointZero];
33 | }
34 |
35 | - (void)test0DegreeAngle {
36 | [self testAngle:0];
37 | }
38 |
39 | - (void)test30DegreeAngle {
40 | [self testAngle:30];
41 | }
42 |
43 | - (void)test90DegreeAngle {
44 | [self testAngle:90];
45 | }
46 |
47 | - (void)test120DegreeAngle {
48 | [self testAngle:120];
49 | }
50 |
51 | - (void)test180DegreeAngle {
52 | [self testAngle:180];
53 | }
54 |
55 | - (void)test225DegreeAngle {
56 | [self testAngle:225];
57 | }
58 |
59 | - (void)test270DegreeAngle {
60 | [self testAngle:270];
61 | }
62 |
63 | - (void)test315DegreeAngle {
64 | [self testAngle:315];
65 | }
66 |
67 | - (void)testAngle:(double)angle {
68 | CGPoint point1 = CGPointMake(1, 0);
69 | CGPoint point2 = CGPointMake(cos(DEGREE_TO_RAD(angle)), -sin(DEGREE_TO_RAD(angle)));
70 | CGFloat angleBetweenPoints = [self.gr angleBetweenPoint:point1 andPoint:point2];
71 | XCTAssertEqualWithAccuracy(angleBetweenPoints, DEGREE_TO_RAD(angle), 0.0001);
72 | }
73 |
74 |
75 | @end
76 |
--------------------------------------------------------------------------------
/FDRotationGestureRecognizerTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | com.francescodilorenzo.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2015 Francesco Di Lorenzo
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/Other/demo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/frankdilo/FDRotationGestureRecognizer/7b28ac0238a4dfaea4bf18b0b470ce8e79e91d6c/Other/demo.gif
--------------------------------------------------------------------------------
/Other/demo.mov:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/frankdilo/FDRotationGestureRecognizer/7b28ac0238a4dfaea4bf18b0b470ce8e79e91d6c/Other/demo.mov
--------------------------------------------------------------------------------
/Other/explanation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/frankdilo/FDRotationGestureRecognizer/7b28ac0238a4dfaea4bf18b0b470ce8e79e91d6c/Other/explanation.png
--------------------------------------------------------------------------------
/Other/myfert.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/frankdilo/FDRotationGestureRecognizer/7b28ac0238a4dfaea4bf18b0b470ce8e79e91d6c/Other/myfert.jpeg
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # FDRotationGestureRecognizer
2 |
3 | A `UIGestureRecognizer` subclass that, once added to a view, allows to easily measure the rotation performed by the user dragging on the screen.
4 |
5 | ## Demo
6 |
7 | This is just a little demo built around the gesture recognizer:
8 |
9 | 
10 |
11 | (Video available [here](https://github.com/frankdilo/FDRotationGestureRecognizer/raw/master/Other/demo.mov) if you don't like gifs.)
12 |
13 | ## How it works
14 |
15 | Basically when the user starts the gesture, the initial tap coordinates are recorded and, as the gesture continues, the angle is updated as explained in this image.
16 |
17 | 
18 |
19 | ## Credits
20 |
21 | I created this component while building the [MyFertility app](https://itunes.apple.com/it/app/my-fertility/id862972591?mt=8) to implement the circular day picker. Thanks to [@dzamir](https://twitter.com/dzamir) and Return Service for letting me open source it :)
22 |
23 | 
--------------------------------------------------------------------------------