├── .gitignore ├── LICENSE.txt ├── Podfile ├── README.md ├── SimpleCam.podspec ├── SimpleCam.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ ├── capezzbr.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ │ └── loganwright.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ ├── capezzbr.xcuserdatad │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ │ ├── SimpleCam.xcscheme │ │ └── xcschememanagement.plist │ └── loganwright.xcuserdatad │ └── xcschemes │ ├── SimpleCam.xcscheme │ └── xcschememanagement.plist ├── SimpleCam ├── AppDelegate.h ├── AppDelegate.m ├── Images.xcassets │ ├── AppIcon.appiconset │ │ ├── 120b.png │ │ ├── 58b.png │ │ ├── 80b.png │ │ └── Contents.json │ └── LaunchImage.launchimage │ │ └── Contents.json ├── Images │ ├── Attribution_PixelLove.png │ ├── SimpleCamCover.png │ ├── landscape_Camera.png │ ├── landscape_Preview.png │ ├── landscape_RotatedPreview.png │ ├── placeit.png │ ├── portrait_Camera.png │ ├── portrait_Preview.png │ ├── portrait_RotatedPreview.png │ └── shutter@2x.png ├── RootViewController.h ├── RootViewController.m ├── SimpleCam-Info.plist ├── SimpleCam-Prefix.pch ├── SimpleCam │ ├── Icons │ │ ├── CameraRotate.png │ │ ├── Download.png │ │ ├── Lightening.png │ │ └── Previous.png │ ├── LICENSE.txt │ ├── SimpleCam.h │ └── SimpleCam.m ├── en.lproj │ └── InfoPlist.strings └── main.m └── SimpleCamTests ├── SimpleCamTests-Info.plist ├── SimpleCamTests.m └── en.lproj └── InfoPlist.strings /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | Pods/ 27 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Mozilla Public License Version 2.0 2 | ================================== 3 | 4 | 1. Definitions 5 | -------------- 6 | 7 | 1.1. "Contributor" 8 | means each individual or legal entity that creates, contributes to 9 | the creation of, or owns Covered Software. 10 | 11 | 1.2. "Contributor Version" 12 | means the combination of the Contributions of others (if any) used 13 | by a Contributor and that particular Contributor's Contribution. 14 | 15 | 1.3. "Contribution" 16 | means Covered Software of a particular Contributor. 17 | 18 | 1.4. "Covered Software" 19 | means Source Code Form to which the initial Contributor has attached 20 | the notice in Exhibit A, the Executable Form of such Source Code 21 | Form, and Modifications of such Source Code Form, in each case 22 | including portions thereof. 23 | 24 | 1.5. "Incompatible With Secondary Licenses" 25 | means 26 | 27 | (a) that the initial Contributor has attached the notice described 28 | in Exhibit B to the Covered Software; or 29 | 30 | (b) that the Covered Software was made available under the terms of 31 | version 1.1 or earlier of the License, but not also under the 32 | terms of a Secondary License. 33 | 34 | 1.6. "Executable Form" 35 | means any form of the work other than Source Code Form. 36 | 37 | 1.7. "Larger Work" 38 | means a work that combines Covered Software with other material, in 39 | a separate file or files, that is not Covered Software. 40 | 41 | 1.8. "License" 42 | means this document. 43 | 44 | 1.9. "Licensable" 45 | means having the right to grant, to the maximum extent possible, 46 | whether at the time of the initial grant or subsequently, any and 47 | all of the rights conveyed by this License. 48 | 49 | 1.10. "Modifications" 50 | means any of the following: 51 | 52 | (a) any file in Source Code Form that results from an addition to, 53 | deletion from, or modification of the contents of Covered 54 | Software; or 55 | 56 | (b) any new file in Source Code Form that contains any Covered 57 | Software. 58 | 59 | 1.11. "Patent Claims" of a Contributor 60 | means any patent claim(s), including without limitation, method, 61 | process, and apparatus claims, in any patent Licensable by such 62 | Contributor that would be infringed, but for the grant of the 63 | License, by the making, using, selling, offering for sale, having 64 | made, import, or transfer of either its Contributions or its 65 | Contributor Version. 66 | 67 | 1.12. "Secondary License" 68 | means either the GNU General Public License, Version 2.0, the GNU 69 | Lesser General Public License, Version 2.1, the GNU Affero General 70 | Public License, Version 3.0, or any later versions of those 71 | licenses. 72 | 73 | 1.13. "Source Code Form" 74 | means the form of the work preferred for making modifications. 75 | 76 | 1.14. "You" (or "Your") 77 | means an individual or a legal entity exercising rights under this 78 | License. For legal entities, "You" includes any entity that 79 | controls, is controlled by, or is under common control with You. For 80 | purposes of this definition, "control" means (a) the power, direct 81 | or indirect, to cause the direction or management of such entity, 82 | whether by contract or otherwise, or (b) ownership of more than 83 | fifty percent (50%) of the outstanding shares or beneficial 84 | ownership of such entity. 85 | 86 | 2. License Grants and Conditions 87 | -------------------------------- 88 | 89 | 2.1. Grants 90 | 91 | Each Contributor hereby grants You a world-wide, royalty-free, 92 | non-exclusive license: 93 | 94 | (a) under intellectual property rights (other than patent or trademark) 95 | Licensable by such Contributor to use, reproduce, make available, 96 | modify, display, perform, distribute, and otherwise exploit its 97 | Contributions, either on an unmodified basis, with Modifications, or 98 | as part of a Larger Work; and 99 | 100 | (b) under Patent Claims of such Contributor to make, use, sell, offer 101 | for sale, have made, import, and otherwise transfer either its 102 | Contributions or its Contributor Version. 103 | 104 | 2.2. Effective Date 105 | 106 | The licenses granted in Section 2.1 with respect to any Contribution 107 | become effective for each Contribution on the date the Contributor first 108 | distributes such Contribution. 109 | 110 | 2.3. Limitations on Grant Scope 111 | 112 | The licenses granted in this Section 2 are the only rights granted under 113 | this License. No additional rights or licenses will be implied from the 114 | distribution or licensing of Covered Software under this License. 115 | Notwithstanding Section 2.1(b) above, no patent license is granted by a 116 | Contributor: 117 | 118 | (a) for any code that a Contributor has removed from Covered Software; 119 | or 120 | 121 | (b) for infringements caused by: (i) Your and any other third party's 122 | modifications of Covered Software, or (ii) the combination of its 123 | Contributions with other software (except as part of its Contributor 124 | Version); or 125 | 126 | (c) under Patent Claims infringed by Covered Software in the absence of 127 | its Contributions. 128 | 129 | This License does not grant any rights in the trademarks, service marks, 130 | or logos of any Contributor (except as may be necessary to comply with 131 | the notice requirements in Section 3.4). 132 | 133 | 2.4. Subsequent Licenses 134 | 135 | No Contributor makes additional grants as a result of Your choice to 136 | distribute the Covered Software under a subsequent version of this 137 | License (see Section 10.2) or under the terms of a Secondary License (if 138 | permitted under the terms of Section 3.3). 139 | 140 | 2.5. Representation 141 | 142 | Each Contributor represents that the Contributor believes its 143 | Contributions are its original creation(s) or it has sufficient rights 144 | to grant the rights to its Contributions conveyed by this License. 145 | 146 | 2.6. Fair Use 147 | 148 | This License is not intended to limit any rights You have under 149 | applicable copyright doctrines of fair use, fair dealing, or other 150 | equivalents. 151 | 152 | 2.7. Conditions 153 | 154 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted 155 | in Section 2.1. 156 | 157 | 3. Responsibilities 158 | ------------------- 159 | 160 | 3.1. Distribution of Source Form 161 | 162 | All distribution of Covered Software in Source Code Form, including any 163 | Modifications that You create or to which You contribute, must be under 164 | the terms of this License. You must inform recipients that the Source 165 | Code Form of the Covered Software is governed by the terms of this 166 | License, and how they can obtain a copy of this License. You may not 167 | attempt to alter or restrict the recipients' rights in the Source Code 168 | Form. 169 | 170 | 3.2. Distribution of Executable Form 171 | 172 | If You distribute Covered Software in Executable Form then: 173 | 174 | (a) such Covered Software must also be made available in Source Code 175 | Form, as described in Section 3.1, and You must inform recipients of 176 | the Executable Form how they can obtain a copy of such Source Code 177 | Form by reasonable means in a timely manner, at a charge no more 178 | than the cost of distribution to the recipient; and 179 | 180 | (b) You may distribute such Executable Form under the terms of this 181 | License, or sublicense it under different terms, provided that the 182 | license for the Executable Form does not attempt to limit or alter 183 | the recipients' rights in the Source Code Form under this License. 184 | 185 | 3.3. Distribution of a Larger Work 186 | 187 | You may create and distribute a Larger Work under terms of Your choice, 188 | provided that You also comply with the requirements of this License for 189 | the Covered Software. If the Larger Work is a combination of Covered 190 | Software with a work governed by one or more Secondary Licenses, and the 191 | Covered Software is not Incompatible With Secondary Licenses, this 192 | License permits You to additionally distribute such Covered Software 193 | under the terms of such Secondary License(s), so that the recipient of 194 | the Larger Work may, at their option, further distribute the Covered 195 | Software under the terms of either this License or such Secondary 196 | License(s). 197 | 198 | 3.4. Notices 199 | 200 | You may not remove or alter the substance of any license notices 201 | (including copyright notices, patent notices, disclaimers of warranty, 202 | or limitations of liability) contained within the Source Code Form of 203 | the Covered Software, except that You may alter any license notices to 204 | the extent required to remedy known factual inaccuracies. 205 | 206 | 3.5. Application of Additional Terms 207 | 208 | You may choose to offer, and to charge a fee for, warranty, support, 209 | indemnity or liability obligations to one or more recipients of Covered 210 | Software. However, You may do so only on Your own behalf, and not on 211 | behalf of any Contributor. You must make it absolutely clear that any 212 | such warranty, support, indemnity, or liability obligation is offered by 213 | You alone, and You hereby agree to indemnify every Contributor for any 214 | liability incurred by such Contributor as a result of warranty, support, 215 | indemnity or liability terms You offer. You may include additional 216 | disclaimers of warranty and limitations of liability specific to any 217 | jurisdiction. 218 | 219 | 4. Inability to Comply Due to Statute or Regulation 220 | --------------------------------------------------- 221 | 222 | If it is impossible for You to comply with any of the terms of this 223 | License with respect to some or all of the Covered Software due to 224 | statute, judicial order, or regulation then You must: (a) comply with 225 | the terms of this License to the maximum extent possible; and (b) 226 | describe the limitations and the code they affect. Such description must 227 | be placed in a text file included with all distributions of the Covered 228 | Software under this License. Except to the extent prohibited by statute 229 | or regulation, such description must be sufficiently detailed for a 230 | recipient of ordinary skill to be able to understand it. 231 | 232 | 5. Termination 233 | -------------- 234 | 235 | 5.1. The rights granted under this License will terminate automatically 236 | if You fail to comply with any of its terms. However, if You become 237 | compliant, then the rights granted under this License from a particular 238 | Contributor are reinstated (a) provisionally, unless and until such 239 | Contributor explicitly and finally terminates Your grants, and (b) on an 240 | ongoing basis, if such Contributor fails to notify You of the 241 | non-compliance by some reasonable means prior to 60 days after You have 242 | come back into compliance. Moreover, Your grants from a particular 243 | Contributor are reinstated on an ongoing basis if such Contributor 244 | notifies You of the non-compliance by some reasonable means, this is the 245 | first time You have received notice of non-compliance with this License 246 | from such Contributor, and You become compliant prior to 30 days after 247 | Your receipt of the notice. 248 | 249 | 5.2. If You initiate litigation against any entity by asserting a patent 250 | infringement claim (excluding declaratory judgment actions, 251 | counter-claims, and cross-claims) alleging that a Contributor Version 252 | directly or indirectly infringes any patent, then the rights granted to 253 | You by any and all Contributors for the Covered Software under Section 254 | 2.1 of this License shall terminate. 255 | 256 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all 257 | end user license agreements (excluding distributors and resellers) which 258 | have been validly granted by You or Your distributors under this License 259 | prior to termination shall survive termination. 260 | 261 | ************************************************************************ 262 | * * 263 | * 6. Disclaimer of Warranty * 264 | * ------------------------- * 265 | * * 266 | * Covered Software is provided under this License on an "as is" * 267 | * basis, without warranty of any kind, either expressed, implied, or * 268 | * statutory, including, without limitation, warranties that the * 269 | * Covered Software is free of defects, merchantable, fit for a * 270 | * particular purpose or non-infringing. The entire risk as to the * 271 | * quality and performance of the Covered Software is with You. * 272 | * Should any Covered Software prove defective in any respect, You * 273 | * (not any Contributor) assume the cost of any necessary servicing, * 274 | * repair, or correction. This disclaimer of warranty constitutes an * 275 | * essential part of this License. No use of any Covered Software is * 276 | * authorized under this License except under this disclaimer. * 277 | * * 278 | ************************************************************************ 279 | 280 | ************************************************************************ 281 | * * 282 | * 7. Limitation of Liability * 283 | * -------------------------- * 284 | * * 285 | * Under no circumstances and under no legal theory, whether tort * 286 | * (including negligence), contract, or otherwise, shall any * 287 | * Contributor, or anyone who distributes Covered Software as * 288 | * permitted above, be liable to You for any direct, indirect, * 289 | * special, incidental, or consequential damages of any character * 290 | * including, without limitation, damages for lost profits, loss of * 291 | * goodwill, work stoppage, computer failure or malfunction, or any * 292 | * and all other commercial damages or losses, even if such party * 293 | * shall have been informed of the possibility of such damages. This * 294 | * limitation of liability shall not apply to liability for death or * 295 | * personal injury resulting from such party's negligence to the * 296 | * extent applicable law prohibits such limitation. Some * 297 | * jurisdictions do not allow the exclusion or limitation of * 298 | * incidental or consequential damages, so this exclusion and * 299 | * limitation may not apply to You. * 300 | * * 301 | ************************************************************************ 302 | 303 | 8. Litigation 304 | ------------- 305 | 306 | Any litigation relating to this License may be brought only in the 307 | courts of a jurisdiction where the defendant maintains its principal 308 | place of business and such litigation shall be governed by laws of that 309 | jurisdiction, without reference to its conflict-of-law provisions. 310 | Nothing in this Section shall prevent a party's ability to bring 311 | cross-claims or counter-claims. 312 | 313 | 9. Miscellaneous 314 | ---------------- 315 | 316 | This License represents the complete agreement concerning the subject 317 | matter hereof. If any provision of this License is held to be 318 | unenforceable, such provision shall be reformed only to the extent 319 | necessary to make it enforceable. Any law or regulation which provides 320 | that the language of a contract shall be construed against the drafter 321 | shall not be used to construe this License against a Contributor. 322 | 323 | 10. Versions of the License 324 | --------------------------- 325 | 326 | 10.1. New Versions 327 | 328 | Mozilla Foundation is the license steward. Except as provided in Section 329 | 10.3, no one other than the license steward has the right to modify or 330 | publish new versions of this License. Each version will be given a 331 | distinguishing version number. 332 | 333 | 10.2. Effect of New Versions 334 | 335 | You may distribute the Covered Software under the terms of the version 336 | of the License under which You originally received the Covered Software, 337 | or under the terms of any subsequent version published by the license 338 | steward. 339 | 340 | 10.3. Modified Versions 341 | 342 | If you create software not governed by this License, and you want to 343 | create a new license for such software, you may create and use a 344 | modified version of this License if you rename the license and remove 345 | any references to the name of the license steward (except to note that 346 | such modified license differs from this License). 347 | 348 | 10.4. Distributing Source Code Form that is Incompatible With Secondary 349 | Licenses 350 | 351 | If You choose to distribute Source Code Form that is Incompatible With 352 | Secondary Licenses under the terms of this version of the License, the 353 | notice described in Exhibit B of this License must be attached. 354 | 355 | Exhibit A - Source Code Form License Notice 356 | ------------------------------------------- 357 | 358 | This Source Code Form is subject to the terms of the Mozilla Public 359 | License, v. 2.0. If a copy of the MPL was not distributed with this 360 | file, You can obtain one at http://mozilla.org/MPL/2.0/. 361 | 362 | If it is not possible or desirable to put the notice in a particular 363 | file, then You may include the notice in a location (such as a LICENSE 364 | file in a relevant directory) where a recipient would be likely to look 365 | for such a notice. 366 | 367 | You may add additional accurate notices of copyright ownership. 368 | 369 | Exhibit B - "Incompatible With Secondary Licenses" Notice 370 | --------------------------------------------------------- 371 | 372 | This Source Code Form is "Incompatible With Secondary Licenses", as 373 | defined by the Mozilla Public License, v. 2.0. -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | platform :ios, '7.0' 2 | 3 | pod 'SimpleCam' 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

SimpleCam

2 | 3 |

A Memory Efficient Drop In Replacement / Alternative for the Native UIImagePicker Camera

4 | 5 |

6 | 7 |

8 | 9 |

Why Do I Need It?

10 | 11 | SimpleCam was created out of the necessity to have high quality photographs while providing a lightweight memory footprint. Apple's UIImagePicker is a wonderful application, but because it has a lot of features and a lot of options, . . . it uses a lot of MEMORY. This can cause crashes, lag, and an overall poor experience when all you wanted was to give the user an opportunity to take a quick picture. 12 | 13 | If you're capturing photographs with UIImagePicker, or via AVFoundation on the highest possible capture resolution, it will return giant image files exceeding thousands of pixels in size. SimpleCam avoids this while still using the highest possible capture resolution by resizing the photo to 2x the size of the phone's screen. This allows the photo to maintain a significantly reduced file size while still looking clean and brilliant on mobile displays. 14 | 15 | I hope you find the project as useful as I did! 16 | 17 |

Features

18 | 30 | 31 |

32 | 33 |

34 | 35 |

36 | Icons generously provided by PixelLove: 37 |

38 |

39 | 40 | 41 | 42 |

43 | 44 | ### CocoaPods 45 | 46 | ``` 47 | pod 'SimpleCam', '~> 0.1' 48 | ``` 49 | 50 | #Adding SimpleCam to Your Project 51 | 52 | ###1. Add SimpleCam Folder to Xcode 53 | 54 | - Unzip SimpleCam 55 | - Drag SimpleCam Folder into your Xcode project 56 | - Make sure "Copy items into destination group's folder (if needed)" is selected 57 | 58 | ###2. Your ViewController.h File 59 | 60 | - Import SimpleCam 61 | - Set up your view controller as a SimpleCam delegate 62 | 63 | ```Obj-C 64 | #import 65 | #import "SimpleCam.h" 66 | 67 | @interface ViewController : UIViewController 68 | 69 | @end 70 | ``` 71 | 72 | ###3. Set Up Delegate 73 | 74 | - Add SimpleCam's Delegate method to your ViewController.m file 75 | - Close SimpleCam 76 | 77 | This is how SimpleCam will notify your ViewController that the user is finished with it. If there is an image, then the user took a picture. If there is not, then the user backed out of the camera without taking a photograph. Make sure to close SimpleCam in this method using SimpleCam's custom close. Otherwise, the captureSession may not close properly and may result in memory leaks. 78 | 79 | ```Obj-C 80 | #pragma mark SIMPLE CAM DELEGATE 81 | 82 | - (void) simpleCam:(SimpleCam *)simpleCam didFinishWithImage:(UIImage *)image { 83 | 84 | if (image) { 85 | // simple cam finished with image 86 | } 87 | else { 88 | // simple cam finished w/o image 89 | } 90 | 91 | // Close simpleCam - use this as opposed to dismissViewController: to properly end photo session 92 | [simpleCam closeWithCompletion:^{ 93 | NSLog(@"SimpleCam is done closing ... "); 94 | // It is safe to launch other ViewControllers, for instance, an editor here. 95 | }]; 96 | } 97 | ``` 98 | 99 | ###4. Launch SimpleCam 100 | 101 | - Add this code wherever you'd like SimpleCam to launch 102 | 103 | ```Obj-C 104 | SimpleCam * simpleCam = [[SimpleCam alloc]init]; 105 | simpleCam.delegate = self; 106 | [self presentViewController:simpleCam animated:YES completion:nil]; 107 | ``` 108 | If you'd like to launch simple cam when the user presses a button, you could add the above code to the buttonPress method, like so: 109 | 110 | ```Obj-C 111 | - (void) buttonPress:(id)sender { 112 | SimpleCam * simpleCam = [[SimpleCam alloc]init]; 113 | simpleCam.delegate = self; 114 | [self presentViewController:simpleCam animated:YES completion:nil]; 115 | } 116 | ``` 117 | That's it, it's as simple as that. SimpleCam will take care of everything else! 118 | 119 | #ChangeLog 120 | 121 | v1.01 Released 19 May 2014 122 | 123 | Thanks @capezzbr & @dkhamsing for their contributions to this commit! 124 | 125 | - You can now capture photos programmatically by calling `[simpleCam capturePhoto]` 126 | - Now supports an overlay control system (more interaction possibilities coming soon!) 127 | - Disable Photo Preview to save photos as soon as they're captured: `simpleCam.disablePhotoPreview = YES` 128 | - New delegate method to be notified of when the camera stream is visible: 129 | 130 | ```ObjC 131 | - (void) simpleCamDidLoadCameraIntoView:(SimpleCam *)simpleCam { 132 | NSLog(@"Camera loaded ... "); 133 | } 134 | ``` 135 | 136 | #Screen Shots 137 | 138 | ###Portrait 139 |
Camera (About To Capture)
140 |

141 | 142 |

143 | 144 |
Preview (Shows Captured Image)
145 |

146 | 147 |

148 | 149 |
Preview - Rotated (Maintains Captured Image Ratio)
150 |

151 | 152 |

153 | 154 | 155 | ###Landscape 156 | 157 |
Camera (About To Capture)
158 |

159 | 160 |

161 | 162 |
Preview (Shows Captured Image)
163 |

164 | 165 |

166 | 167 |
Preview - Rotated (Maintains Captured Image Ratio)
168 |

169 | 170 |

171 | -------------------------------------------------------------------------------- /SimpleCam.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod lib lint NAME.podspec' to ensure this is a 3 | # valid spec and remove all comments before submitting the spec. 4 | # 5 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html 6 | # 7 | Pod::Spec.new do |s| 8 | s.name = "SimpleCam" 9 | s.version = "0.1.5" 10 | s.summary = "A Memory Efficient Drop In Replacement / Alternative for the Native UIImagePicker Camera" 11 | s.description = "SimpleCam was created out of the necessity to have high quality photographs while providing a lightweight memory footprint. Apple's UIImagePicker is a wonderful application, but because it has a lot of features and a lot of options, . . . it uses a lot of MEMORY. This can cause crashes, lag, and an overall poor experience when all you wanted was to give the user an opportunity to take a quick picture. 12 | 13 | If you're capturing photographs with UIImagePicker, or via AVFoundation on the highest possible capture resolution, it will return giant image files exceeding thousands of pixels in size. SimpleCam avoids this while still using the highest possible capture resolution by resizing the photo to 2x the size of the phone's screen. This allows the photo to maintain a significantly reduced file size while still looking clean and brilliant on mobile displays. 14 | 15 | I hope you find the project as useful as I did!" 16 | s.homepage = "http://github.com/LoganWright" 17 | s.screenshots = "https://github.com/LoganWright/SimpleCam/blob/master/SimpleCam/Images/SimpleCamCover.png?raw=true" 18 | s.license = {:type => 'MPL 2.0'} 19 | s.author = { "Logan Wright" => "logan.william.wright@gmail.com" } 20 | s.source = { :git => "https://github.com/LoganWright/SimpleCam.git", :tag => s.version.to_s } 21 | s.social_media_url = 'https://twitter.com/logmaestro' 22 | 23 | s.platform = :ios, '7.0' 24 | # s.ios.deployment_target = '5.0' 25 | # s.osx.deployment_target = '10.7' 26 | s.requires_arc = true 27 | 28 | s.source_files = 'SimpleCam/SimpleCam/SimpleCam.{h,m}' 29 | s.resources = 'SimpleCam/SimpleCam/Icons/*.png' 30 | 31 | # s.ios.exclude_files = 'Classes/osx' 32 | # s.osx.exclude_files = 'Classes/ios' 33 | # s.public_header_files = 'Classes/**/*.h' 34 | # s.frameworks = 'SomeFramework', 'AnotherFramework' 35 | # s.dependency 'JSONKit', '~> 1.4' 36 | end 37 | -------------------------------------------------------------------------------- /SimpleCam.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 8058D4E618E9C72F0031A3B1 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8058D4E518E9C72F0031A3B1 /* Foundation.framework */; }; 11 | 8058D4E818E9C72F0031A3B1 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8058D4E718E9C72F0031A3B1 /* CoreGraphics.framework */; }; 12 | 8058D4EA18E9C72F0031A3B1 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8058D4E918E9C72F0031A3B1 /* UIKit.framework */; }; 13 | 8058D4F018E9C72F0031A3B1 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8058D4EE18E9C72F0031A3B1 /* InfoPlist.strings */; }; 14 | 8058D4F218E9C72F0031A3B1 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 8058D4F118E9C72F0031A3B1 /* main.m */; }; 15 | 8058D4F618E9C72F0031A3B1 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8058D4F518E9C72F0031A3B1 /* AppDelegate.m */; }; 16 | 8058D4F818E9C72F0031A3B1 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8058D4F718E9C72F0031A3B1 /* Images.xcassets */; }; 17 | 8058D4FF18E9C72F0031A3B1 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8058D4FE18E9C72F0031A3B1 /* XCTest.framework */; }; 18 | 8058D50018E9C72F0031A3B1 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8058D4E518E9C72F0031A3B1 /* Foundation.framework */; }; 19 | 8058D50118E9C72F0031A3B1 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8058D4E918E9C72F0031A3B1 /* UIKit.framework */; }; 20 | 8058D50918E9C72F0031A3B1 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8058D50718E9C72F0031A3B1 /* InfoPlist.strings */; }; 21 | 8058D50B18E9C72F0031A3B1 /* SimpleCamTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 8058D50A18E9C72F0031A3B1 /* SimpleCamTests.m */; }; 22 | 8058D51D18E9C7C70031A3B1 /* CameraRotate.png in Resources */ = {isa = PBXBuildFile; fileRef = 8058D51618E9C7C70031A3B1 /* CameraRotate.png */; }; 23 | 8058D51E18E9C7C70031A3B1 /* Download.png in Resources */ = {isa = PBXBuildFile; fileRef = 8058D51718E9C7C70031A3B1 /* Download.png */; }; 24 | 8058D51F18E9C7C70031A3B1 /* Lightening.png in Resources */ = {isa = PBXBuildFile; fileRef = 8058D51818E9C7C70031A3B1 /* Lightening.png */; }; 25 | 8058D52018E9C7C70031A3B1 /* Previous.png in Resources */ = {isa = PBXBuildFile; fileRef = 8058D51918E9C7C70031A3B1 /* Previous.png */; }; 26 | 8058D52118E9C7C70031A3B1 /* LICENSE.txt in Resources */ = {isa = PBXBuildFile; fileRef = 8058D51A18E9C7C70031A3B1 /* LICENSE.txt */; }; 27 | 8058D52218E9C7C70031A3B1 /* SimpleCam.m in Sources */ = {isa = PBXBuildFile; fileRef = 8058D51C18E9C7C70031A3B1 /* SimpleCam.m */; }; 28 | 8058D53818E9C7DD0031A3B1 /* RootViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8058D53718E9C7DD0031A3B1 /* RootViewController.m */; }; 29 | 8058D54118E9CDD50031A3B1 /* SimpleCamCover.png in Resources */ = {isa = PBXBuildFile; fileRef = 8058D53F18E9CDD50031A3B1 /* SimpleCamCover.png */; }; 30 | 8058D54218E9CDD50031A3B1 /* placeit.png in Resources */ = {isa = PBXBuildFile; fileRef = 8058D54018E9CDD50031A3B1 /* placeit.png */; }; 31 | 8058D54918E9D1C70031A3B1 /* landscape_Camera.png in Resources */ = {isa = PBXBuildFile; fileRef = 8058D54318E9D1C70031A3B1 /* landscape_Camera.png */; }; 32 | 8058D54A18E9D1C70031A3B1 /* landscape_Preview.png in Resources */ = {isa = PBXBuildFile; fileRef = 8058D54418E9D1C70031A3B1 /* landscape_Preview.png */; }; 33 | 8058D54B18E9D1C70031A3B1 /* portrait_RotatedPreview.png in Resources */ = {isa = PBXBuildFile; fileRef = 8058D54518E9D1C70031A3B1 /* portrait_RotatedPreview.png */; }; 34 | 8058D54C18E9D1C70031A3B1 /* portrait_Camera.png in Resources */ = {isa = PBXBuildFile; fileRef = 8058D54618E9D1C70031A3B1 /* portrait_Camera.png */; }; 35 | 8058D54D18E9D1C70031A3B1 /* portrait_Preview.png in Resources */ = {isa = PBXBuildFile; fileRef = 8058D54718E9D1C70031A3B1 /* portrait_Preview.png */; }; 36 | 8058D54E18E9D1C70031A3B1 /* landscape_RotatedPreview.png in Resources */ = {isa = PBXBuildFile; fileRef = 8058D54818E9D1C70031A3B1 /* landscape_RotatedPreview.png */; }; 37 | 8058D55618E9D56A0031A3B1 /* Attribution_PixelLove.png in Resources */ = {isa = PBXBuildFile; fileRef = 8058D55518E9D56A0031A3B1 /* Attribution_PixelLove.png */; }; 38 | CE501516192A807000C7E404 /* shutter@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = CE501515192A807000C7E404 /* shutter@2x.png */; }; 39 | /* End PBXBuildFile section */ 40 | 41 | /* Begin PBXContainerItemProxy section */ 42 | 8058D50218E9C72F0031A3B1 /* PBXContainerItemProxy */ = { 43 | isa = PBXContainerItemProxy; 44 | containerPortal = 8058D4DA18E9C72F0031A3B1 /* Project object */; 45 | proxyType = 1; 46 | remoteGlobalIDString = 8058D4E118E9C72F0031A3B1; 47 | remoteInfo = SimpleCam; 48 | }; 49 | /* End PBXContainerItemProxy section */ 50 | 51 | /* Begin PBXFileReference section */ 52 | 8058D4E218E9C72F0031A3B1 /* SimpleCam.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SimpleCam.app; sourceTree = BUILT_PRODUCTS_DIR; }; 53 | 8058D4E518E9C72F0031A3B1 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 54 | 8058D4E718E9C72F0031A3B1 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 55 | 8058D4E918E9C72F0031A3B1 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 56 | 8058D4ED18E9C72F0031A3B1 /* SimpleCam-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "SimpleCam-Info.plist"; sourceTree = ""; }; 57 | 8058D4EF18E9C72F0031A3B1 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 58 | 8058D4F118E9C72F0031A3B1 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 59 | 8058D4F318E9C72F0031A3B1 /* SimpleCam-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SimpleCam-Prefix.pch"; sourceTree = ""; }; 60 | 8058D4F418E9C72F0031A3B1 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 61 | 8058D4F518E9C72F0031A3B1 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 62 | 8058D4F718E9C72F0031A3B1 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 63 | 8058D4FD18E9C72F0031A3B1 /* SimpleCamTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SimpleCamTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 64 | 8058D4FE18E9C72F0031A3B1 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 65 | 8058D50618E9C72F0031A3B1 /* SimpleCamTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "SimpleCamTests-Info.plist"; sourceTree = ""; }; 66 | 8058D50818E9C72F0031A3B1 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 67 | 8058D50A18E9C72F0031A3B1 /* SimpleCamTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SimpleCamTests.m; sourceTree = ""; }; 68 | 8058D51618E9C7C70031A3B1 /* CameraRotate.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = CameraRotate.png; sourceTree = ""; }; 69 | 8058D51718E9C7C70031A3B1 /* Download.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Download.png; sourceTree = ""; }; 70 | 8058D51818E9C7C70031A3B1 /* Lightening.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Lightening.png; sourceTree = ""; }; 71 | 8058D51918E9C7C70031A3B1 /* Previous.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Previous.png; sourceTree = ""; }; 72 | 8058D51A18E9C7C70031A3B1 /* LICENSE.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE.txt; sourceTree = ""; }; 73 | 8058D51B18E9C7C70031A3B1 /* SimpleCam.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleCam.h; sourceTree = ""; }; 74 | 8058D51C18E9C7C70031A3B1 /* SimpleCam.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SimpleCam.m; sourceTree = ""; }; 75 | 8058D53618E9C7DD0031A3B1 /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = ""; }; 76 | 8058D53718E9C7DD0031A3B1 /* RootViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RootViewController.m; sourceTree = ""; }; 77 | 8058D53F18E9CDD50031A3B1 /* SimpleCamCover.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = SimpleCamCover.png; sourceTree = ""; }; 78 | 8058D54018E9CDD50031A3B1 /* placeit.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = placeit.png; sourceTree = ""; }; 79 | 8058D54318E9D1C70031A3B1 /* landscape_Camera.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = landscape_Camera.png; sourceTree = ""; }; 80 | 8058D54418E9D1C70031A3B1 /* landscape_Preview.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = landscape_Preview.png; sourceTree = ""; }; 81 | 8058D54518E9D1C70031A3B1 /* portrait_RotatedPreview.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = portrait_RotatedPreview.png; sourceTree = ""; }; 82 | 8058D54618E9D1C70031A3B1 /* portrait_Camera.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = portrait_Camera.png; sourceTree = ""; }; 83 | 8058D54718E9D1C70031A3B1 /* portrait_Preview.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = portrait_Preview.png; sourceTree = ""; }; 84 | 8058D54818E9D1C70031A3B1 /* landscape_RotatedPreview.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = landscape_RotatedPreview.png; sourceTree = ""; }; 85 | 8058D55518E9D56A0031A3B1 /* Attribution_PixelLove.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Attribution_PixelLove.png; sourceTree = ""; }; 86 | CE501515192A807000C7E404 /* shutter@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "shutter@2x.png"; sourceTree = ""; }; 87 | /* End PBXFileReference section */ 88 | 89 | /* Begin PBXFrameworksBuildPhase section */ 90 | 8058D4DF18E9C72F0031A3B1 /* Frameworks */ = { 91 | isa = PBXFrameworksBuildPhase; 92 | buildActionMask = 2147483647; 93 | files = ( 94 | 8058D4E818E9C72F0031A3B1 /* CoreGraphics.framework in Frameworks */, 95 | 8058D4EA18E9C72F0031A3B1 /* UIKit.framework in Frameworks */, 96 | 8058D4E618E9C72F0031A3B1 /* Foundation.framework in Frameworks */, 97 | ); 98 | runOnlyForDeploymentPostprocessing = 0; 99 | }; 100 | 8058D4FA18E9C72F0031A3B1 /* Frameworks */ = { 101 | isa = PBXFrameworksBuildPhase; 102 | buildActionMask = 2147483647; 103 | files = ( 104 | 8058D4FF18E9C72F0031A3B1 /* XCTest.framework in Frameworks */, 105 | 8058D50118E9C72F0031A3B1 /* UIKit.framework in Frameworks */, 106 | 8058D50018E9C72F0031A3B1 /* Foundation.framework in Frameworks */, 107 | ); 108 | runOnlyForDeploymentPostprocessing = 0; 109 | }; 110 | /* End PBXFrameworksBuildPhase section */ 111 | 112 | /* Begin PBXGroup section */ 113 | 8058D4D918E9C72F0031A3B1 = { 114 | isa = PBXGroup; 115 | children = ( 116 | 8058D4EB18E9C72F0031A3B1 /* SimpleCam */, 117 | 8058D50418E9C72F0031A3B1 /* SimpleCamTests */, 118 | 8058D4E418E9C72F0031A3B1 /* Frameworks */, 119 | 8058D4E318E9C72F0031A3B1 /* Products */, 120 | ); 121 | sourceTree = ""; 122 | }; 123 | 8058D4E318E9C72F0031A3B1 /* Products */ = { 124 | isa = PBXGroup; 125 | children = ( 126 | 8058D4E218E9C72F0031A3B1 /* SimpleCam.app */, 127 | 8058D4FD18E9C72F0031A3B1 /* SimpleCamTests.xctest */, 128 | ); 129 | name = Products; 130 | sourceTree = ""; 131 | }; 132 | 8058D4E418E9C72F0031A3B1 /* Frameworks */ = { 133 | isa = PBXGroup; 134 | children = ( 135 | 8058D4E518E9C72F0031A3B1 /* Foundation.framework */, 136 | 8058D4E718E9C72F0031A3B1 /* CoreGraphics.framework */, 137 | 8058D4E918E9C72F0031A3B1 /* UIKit.framework */, 138 | 8058D4FE18E9C72F0031A3B1 /* XCTest.framework */, 139 | ); 140 | name = Frameworks; 141 | sourceTree = ""; 142 | }; 143 | 8058D4EB18E9C72F0031A3B1 /* SimpleCam */ = { 144 | isa = PBXGroup; 145 | children = ( 146 | 8058D52318E9C7D00031A3B1 /* Images */, 147 | 8058D51418E9C7C70031A3B1 /* SimpleCam */, 148 | 8058D4F418E9C72F0031A3B1 /* AppDelegate.h */, 149 | 8058D4F518E9C72F0031A3B1 /* AppDelegate.m */, 150 | 8058D53618E9C7DD0031A3B1 /* RootViewController.h */, 151 | 8058D53718E9C7DD0031A3B1 /* RootViewController.m */, 152 | 8058D4F718E9C72F0031A3B1 /* Images.xcassets */, 153 | 8058D4EC18E9C72F0031A3B1 /* Supporting Files */, 154 | ); 155 | path = SimpleCam; 156 | sourceTree = ""; 157 | }; 158 | 8058D4EC18E9C72F0031A3B1 /* Supporting Files */ = { 159 | isa = PBXGroup; 160 | children = ( 161 | 8058D4ED18E9C72F0031A3B1 /* SimpleCam-Info.plist */, 162 | 8058D4EE18E9C72F0031A3B1 /* InfoPlist.strings */, 163 | 8058D4F118E9C72F0031A3B1 /* main.m */, 164 | 8058D4F318E9C72F0031A3B1 /* SimpleCam-Prefix.pch */, 165 | ); 166 | name = "Supporting Files"; 167 | sourceTree = ""; 168 | }; 169 | 8058D50418E9C72F0031A3B1 /* SimpleCamTests */ = { 170 | isa = PBXGroup; 171 | children = ( 172 | 8058D50A18E9C72F0031A3B1 /* SimpleCamTests.m */, 173 | 8058D50518E9C72F0031A3B1 /* Supporting Files */, 174 | ); 175 | path = SimpleCamTests; 176 | sourceTree = ""; 177 | }; 178 | 8058D50518E9C72F0031A3B1 /* Supporting Files */ = { 179 | isa = PBXGroup; 180 | children = ( 181 | 8058D50618E9C72F0031A3B1 /* SimpleCamTests-Info.plist */, 182 | 8058D50718E9C72F0031A3B1 /* InfoPlist.strings */, 183 | ); 184 | name = "Supporting Files"; 185 | sourceTree = ""; 186 | }; 187 | 8058D51418E9C7C70031A3B1 /* SimpleCam */ = { 188 | isa = PBXGroup; 189 | children = ( 190 | 8058D51518E9C7C70031A3B1 /* Icons */, 191 | 8058D51A18E9C7C70031A3B1 /* LICENSE.txt */, 192 | 8058D51B18E9C7C70031A3B1 /* SimpleCam.h */, 193 | 8058D51C18E9C7C70031A3B1 /* SimpleCam.m */, 194 | ); 195 | path = SimpleCam; 196 | sourceTree = ""; 197 | }; 198 | 8058D51518E9C7C70031A3B1 /* Icons */ = { 199 | isa = PBXGroup; 200 | children = ( 201 | 8058D51618E9C7C70031A3B1 /* CameraRotate.png */, 202 | 8058D51718E9C7C70031A3B1 /* Download.png */, 203 | 8058D51818E9C7C70031A3B1 /* Lightening.png */, 204 | 8058D51918E9C7C70031A3B1 /* Previous.png */, 205 | ); 206 | path = Icons; 207 | sourceTree = ""; 208 | }; 209 | 8058D52318E9C7D00031A3B1 /* Images */ = { 210 | isa = PBXGroup; 211 | children = ( 212 | 8058D55518E9D56A0031A3B1 /* Attribution_PixelLove.png */, 213 | 8058D54318E9D1C70031A3B1 /* landscape_Camera.png */, 214 | 8058D54418E9D1C70031A3B1 /* landscape_Preview.png */, 215 | 8058D54818E9D1C70031A3B1 /* landscape_RotatedPreview.png */, 216 | 8058D54018E9CDD50031A3B1 /* placeit.png */, 217 | 8058D54618E9D1C70031A3B1 /* portrait_Camera.png */, 218 | 8058D54718E9D1C70031A3B1 /* portrait_Preview.png */, 219 | 8058D54518E9D1C70031A3B1 /* portrait_RotatedPreview.png */, 220 | CE501515192A807000C7E404 /* shutter@2x.png */, 221 | 8058D53F18E9CDD50031A3B1 /* SimpleCamCover.png */, 222 | ); 223 | path = Images; 224 | sourceTree = ""; 225 | }; 226 | /* End PBXGroup section */ 227 | 228 | /* Begin PBXNativeTarget section */ 229 | 8058D4E118E9C72F0031A3B1 /* SimpleCam */ = { 230 | isa = PBXNativeTarget; 231 | buildConfigurationList = 8058D50E18E9C72F0031A3B1 /* Build configuration list for PBXNativeTarget "SimpleCam" */; 232 | buildPhases = ( 233 | 8058D4DE18E9C72F0031A3B1 /* Sources */, 234 | 8058D4DF18E9C72F0031A3B1 /* Frameworks */, 235 | 8058D4E018E9C72F0031A3B1 /* Resources */, 236 | ); 237 | buildRules = ( 238 | ); 239 | dependencies = ( 240 | ); 241 | name = SimpleCam; 242 | productName = SimpleCam; 243 | productReference = 8058D4E218E9C72F0031A3B1 /* SimpleCam.app */; 244 | productType = "com.apple.product-type.application"; 245 | }; 246 | 8058D4FC18E9C72F0031A3B1 /* SimpleCamTests */ = { 247 | isa = PBXNativeTarget; 248 | buildConfigurationList = 8058D51118E9C72F0031A3B1 /* Build configuration list for PBXNativeTarget "SimpleCamTests" */; 249 | buildPhases = ( 250 | 8058D4F918E9C72F0031A3B1 /* Sources */, 251 | 8058D4FA18E9C72F0031A3B1 /* Frameworks */, 252 | 8058D4FB18E9C72F0031A3B1 /* Resources */, 253 | ); 254 | buildRules = ( 255 | ); 256 | dependencies = ( 257 | 8058D50318E9C72F0031A3B1 /* PBXTargetDependency */, 258 | ); 259 | name = SimpleCamTests; 260 | productName = SimpleCamTests; 261 | productReference = 8058D4FD18E9C72F0031A3B1 /* SimpleCamTests.xctest */; 262 | productType = "com.apple.product-type.bundle.unit-test"; 263 | }; 264 | /* End PBXNativeTarget section */ 265 | 266 | /* Begin PBXProject section */ 267 | 8058D4DA18E9C72F0031A3B1 /* Project object */ = { 268 | isa = PBXProject; 269 | attributes = { 270 | LastUpgradeCheck = 0510; 271 | ORGANIZATIONNAME = "Logan Wright"; 272 | TargetAttributes = { 273 | 8058D4FC18E9C72F0031A3B1 = { 274 | TestTargetID = 8058D4E118E9C72F0031A3B1; 275 | }; 276 | }; 277 | }; 278 | buildConfigurationList = 8058D4DD18E9C72F0031A3B1 /* Build configuration list for PBXProject "SimpleCam" */; 279 | compatibilityVersion = "Xcode 3.2"; 280 | developmentRegion = English; 281 | hasScannedForEncodings = 0; 282 | knownRegions = ( 283 | en, 284 | ); 285 | mainGroup = 8058D4D918E9C72F0031A3B1; 286 | productRefGroup = 8058D4E318E9C72F0031A3B1 /* Products */; 287 | projectDirPath = ""; 288 | projectRoot = ""; 289 | targets = ( 290 | 8058D4E118E9C72F0031A3B1 /* SimpleCam */, 291 | 8058D4FC18E9C72F0031A3B1 /* SimpleCamTests */, 292 | ); 293 | }; 294 | /* End PBXProject section */ 295 | 296 | /* Begin PBXResourcesBuildPhase section */ 297 | 8058D4E018E9C72F0031A3B1 /* Resources */ = { 298 | isa = PBXResourcesBuildPhase; 299 | buildActionMask = 2147483647; 300 | files = ( 301 | 8058D51D18E9C7C70031A3B1 /* CameraRotate.png in Resources */, 302 | 8058D4F018E9C72F0031A3B1 /* InfoPlist.strings in Resources */, 303 | 8058D51F18E9C7C70031A3B1 /* Lightening.png in Resources */, 304 | 8058D4F818E9C72F0031A3B1 /* Images.xcassets in Resources */, 305 | 8058D54A18E9D1C70031A3B1 /* landscape_Preview.png in Resources */, 306 | 8058D52018E9C7C70031A3B1 /* Previous.png in Resources */, 307 | 8058D54B18E9D1C70031A3B1 /* portrait_RotatedPreview.png in Resources */, 308 | CE501516192A807000C7E404 /* shutter@2x.png in Resources */, 309 | 8058D54C18E9D1C70031A3B1 /* portrait_Camera.png in Resources */, 310 | 8058D55618E9D56A0031A3B1 /* Attribution_PixelLove.png in Resources */, 311 | 8058D54118E9CDD50031A3B1 /* SimpleCamCover.png in Resources */, 312 | 8058D54D18E9D1C70031A3B1 /* portrait_Preview.png in Resources */, 313 | 8058D54918E9D1C70031A3B1 /* landscape_Camera.png in Resources */, 314 | 8058D54218E9CDD50031A3B1 /* placeit.png in Resources */, 315 | 8058D54E18E9D1C70031A3B1 /* landscape_RotatedPreview.png in Resources */, 316 | 8058D51E18E9C7C70031A3B1 /* Download.png in Resources */, 317 | 8058D52118E9C7C70031A3B1 /* LICENSE.txt in Resources */, 318 | ); 319 | runOnlyForDeploymentPostprocessing = 0; 320 | }; 321 | 8058D4FB18E9C72F0031A3B1 /* Resources */ = { 322 | isa = PBXResourcesBuildPhase; 323 | buildActionMask = 2147483647; 324 | files = ( 325 | 8058D50918E9C72F0031A3B1 /* InfoPlist.strings in Resources */, 326 | ); 327 | runOnlyForDeploymentPostprocessing = 0; 328 | }; 329 | /* End PBXResourcesBuildPhase section */ 330 | 331 | /* Begin PBXSourcesBuildPhase section */ 332 | 8058D4DE18E9C72F0031A3B1 /* Sources */ = { 333 | isa = PBXSourcesBuildPhase; 334 | buildActionMask = 2147483647; 335 | files = ( 336 | 8058D4F618E9C72F0031A3B1 /* AppDelegate.m in Sources */, 337 | 8058D52218E9C7C70031A3B1 /* SimpleCam.m in Sources */, 338 | 8058D53818E9C7DD0031A3B1 /* RootViewController.m in Sources */, 339 | 8058D4F218E9C72F0031A3B1 /* main.m in Sources */, 340 | ); 341 | runOnlyForDeploymentPostprocessing = 0; 342 | }; 343 | 8058D4F918E9C72F0031A3B1 /* Sources */ = { 344 | isa = PBXSourcesBuildPhase; 345 | buildActionMask = 2147483647; 346 | files = ( 347 | 8058D50B18E9C72F0031A3B1 /* SimpleCamTests.m in Sources */, 348 | ); 349 | runOnlyForDeploymentPostprocessing = 0; 350 | }; 351 | /* End PBXSourcesBuildPhase section */ 352 | 353 | /* Begin PBXTargetDependency section */ 354 | 8058D50318E9C72F0031A3B1 /* PBXTargetDependency */ = { 355 | isa = PBXTargetDependency; 356 | target = 8058D4E118E9C72F0031A3B1 /* SimpleCam */; 357 | targetProxy = 8058D50218E9C72F0031A3B1 /* PBXContainerItemProxy */; 358 | }; 359 | /* End PBXTargetDependency section */ 360 | 361 | /* Begin PBXVariantGroup section */ 362 | 8058D4EE18E9C72F0031A3B1 /* InfoPlist.strings */ = { 363 | isa = PBXVariantGroup; 364 | children = ( 365 | 8058D4EF18E9C72F0031A3B1 /* en */, 366 | ); 367 | name = InfoPlist.strings; 368 | sourceTree = ""; 369 | }; 370 | 8058D50718E9C72F0031A3B1 /* InfoPlist.strings */ = { 371 | isa = PBXVariantGroup; 372 | children = ( 373 | 8058D50818E9C72F0031A3B1 /* en */, 374 | ); 375 | name = InfoPlist.strings; 376 | sourceTree = ""; 377 | }; 378 | /* End PBXVariantGroup section */ 379 | 380 | /* Begin XCBuildConfiguration section */ 381 | 8058D50C18E9C72F0031A3B1 /* Debug */ = { 382 | isa = XCBuildConfiguration; 383 | buildSettings = { 384 | ALWAYS_SEARCH_USER_PATHS = NO; 385 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 386 | CLANG_CXX_LIBRARY = "libc++"; 387 | CLANG_ENABLE_MODULES = YES; 388 | CLANG_ENABLE_OBJC_ARC = YES; 389 | CLANG_WARN_BOOL_CONVERSION = YES; 390 | CLANG_WARN_CONSTANT_CONVERSION = YES; 391 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 392 | CLANG_WARN_EMPTY_BODY = YES; 393 | CLANG_WARN_ENUM_CONVERSION = YES; 394 | CLANG_WARN_INT_CONVERSION = YES; 395 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 396 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 397 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 398 | COPY_PHASE_STRIP = NO; 399 | GCC_C_LANGUAGE_STANDARD = gnu99; 400 | GCC_DYNAMIC_NO_PIC = NO; 401 | GCC_OPTIMIZATION_LEVEL = 0; 402 | GCC_PREPROCESSOR_DEFINITIONS = ( 403 | "DEBUG=1", 404 | "$(inherited)", 405 | ); 406 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 407 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 408 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 409 | GCC_WARN_UNDECLARED_SELECTOR = YES; 410 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 411 | GCC_WARN_UNUSED_FUNCTION = YES; 412 | GCC_WARN_UNUSED_VARIABLE = YES; 413 | IPHONEOS_DEPLOYMENT_TARGET = 7.1; 414 | ONLY_ACTIVE_ARCH = YES; 415 | SDKROOT = iphoneos; 416 | }; 417 | name = Debug; 418 | }; 419 | 8058D50D18E9C72F0031A3B1 /* Release */ = { 420 | isa = XCBuildConfiguration; 421 | buildSettings = { 422 | ALWAYS_SEARCH_USER_PATHS = NO; 423 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 424 | CLANG_CXX_LIBRARY = "libc++"; 425 | CLANG_ENABLE_MODULES = YES; 426 | CLANG_ENABLE_OBJC_ARC = YES; 427 | CLANG_WARN_BOOL_CONVERSION = YES; 428 | CLANG_WARN_CONSTANT_CONVERSION = YES; 429 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 430 | CLANG_WARN_EMPTY_BODY = YES; 431 | CLANG_WARN_ENUM_CONVERSION = YES; 432 | CLANG_WARN_INT_CONVERSION = YES; 433 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 434 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 435 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 436 | COPY_PHASE_STRIP = YES; 437 | ENABLE_NS_ASSERTIONS = NO; 438 | GCC_C_LANGUAGE_STANDARD = gnu99; 439 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 440 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 441 | GCC_WARN_UNDECLARED_SELECTOR = YES; 442 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 443 | GCC_WARN_UNUSED_FUNCTION = YES; 444 | GCC_WARN_UNUSED_VARIABLE = YES; 445 | IPHONEOS_DEPLOYMENT_TARGET = 7.1; 446 | SDKROOT = iphoneos; 447 | VALIDATE_PRODUCT = YES; 448 | }; 449 | name = Release; 450 | }; 451 | 8058D50F18E9C72F0031A3B1 /* Debug */ = { 452 | isa = XCBuildConfiguration; 453 | buildSettings = { 454 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 455 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 456 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 457 | GCC_PREFIX_HEADER = "SimpleCam/SimpleCam-Prefix.pch"; 458 | INFOPLIST_FILE = "SimpleCam/SimpleCam-Info.plist"; 459 | PRODUCT_NAME = "$(TARGET_NAME)"; 460 | USER_HEADER_SEARCH_PATHS = ""; 461 | WRAPPER_EXTENSION = app; 462 | }; 463 | name = Debug; 464 | }; 465 | 8058D51018E9C72F0031A3B1 /* Release */ = { 466 | isa = XCBuildConfiguration; 467 | buildSettings = { 468 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 469 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 470 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 471 | GCC_PREFIX_HEADER = "SimpleCam/SimpleCam-Prefix.pch"; 472 | INFOPLIST_FILE = "SimpleCam/SimpleCam-Info.plist"; 473 | PRODUCT_NAME = "$(TARGET_NAME)"; 474 | USER_HEADER_SEARCH_PATHS = ""; 475 | WRAPPER_EXTENSION = app; 476 | }; 477 | name = Release; 478 | }; 479 | 8058D51218E9C72F0031A3B1 /* Debug */ = { 480 | isa = XCBuildConfiguration; 481 | buildSettings = { 482 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/SimpleCam.app/SimpleCam"; 483 | FRAMEWORK_SEARCH_PATHS = ( 484 | "$(SDKROOT)/Developer/Library/Frameworks", 485 | "$(inherited)", 486 | "$(DEVELOPER_FRAMEWORKS_DIR)", 487 | ); 488 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 489 | GCC_PREFIX_HEADER = "SimpleCam/SimpleCam-Prefix.pch"; 490 | GCC_PREPROCESSOR_DEFINITIONS = ( 491 | "DEBUG=1", 492 | "$(inherited)", 493 | ); 494 | INFOPLIST_FILE = "SimpleCamTests/SimpleCamTests-Info.plist"; 495 | PRODUCT_NAME = "$(TARGET_NAME)"; 496 | TEST_HOST = "$(BUNDLE_LOADER)"; 497 | WRAPPER_EXTENSION = xctest; 498 | }; 499 | name = Debug; 500 | }; 501 | 8058D51318E9C72F0031A3B1 /* Release */ = { 502 | isa = XCBuildConfiguration; 503 | buildSettings = { 504 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/SimpleCam.app/SimpleCam"; 505 | FRAMEWORK_SEARCH_PATHS = ( 506 | "$(SDKROOT)/Developer/Library/Frameworks", 507 | "$(inherited)", 508 | "$(DEVELOPER_FRAMEWORKS_DIR)", 509 | ); 510 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 511 | GCC_PREFIX_HEADER = "SimpleCam/SimpleCam-Prefix.pch"; 512 | INFOPLIST_FILE = "SimpleCamTests/SimpleCamTests-Info.plist"; 513 | PRODUCT_NAME = "$(TARGET_NAME)"; 514 | TEST_HOST = "$(BUNDLE_LOADER)"; 515 | WRAPPER_EXTENSION = xctest; 516 | }; 517 | name = Release; 518 | }; 519 | /* End XCBuildConfiguration section */ 520 | 521 | /* Begin XCConfigurationList section */ 522 | 8058D4DD18E9C72F0031A3B1 /* Build configuration list for PBXProject "SimpleCam" */ = { 523 | isa = XCConfigurationList; 524 | buildConfigurations = ( 525 | 8058D50C18E9C72F0031A3B1 /* Debug */, 526 | 8058D50D18E9C72F0031A3B1 /* Release */, 527 | ); 528 | defaultConfigurationIsVisible = 0; 529 | defaultConfigurationName = Release; 530 | }; 531 | 8058D50E18E9C72F0031A3B1 /* Build configuration list for PBXNativeTarget "SimpleCam" */ = { 532 | isa = XCConfigurationList; 533 | buildConfigurations = ( 534 | 8058D50F18E9C72F0031A3B1 /* Debug */, 535 | 8058D51018E9C72F0031A3B1 /* Release */, 536 | ); 537 | defaultConfigurationIsVisible = 0; 538 | defaultConfigurationName = Release; 539 | }; 540 | 8058D51118E9C72F0031A3B1 /* Build configuration list for PBXNativeTarget "SimpleCamTests" */ = { 541 | isa = XCConfigurationList; 542 | buildConfigurations = ( 543 | 8058D51218E9C72F0031A3B1 /* Debug */, 544 | 8058D51318E9C72F0031A3B1 /* Release */, 545 | ); 546 | defaultConfigurationIsVisible = 0; 547 | defaultConfigurationName = Release; 548 | }; 549 | /* End XCConfigurationList section */ 550 | }; 551 | rootObject = 8058D4DA18E9C72F0031A3B1 /* Project object */; 552 | } 553 | -------------------------------------------------------------------------------- /SimpleCam.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SimpleCam.xcodeproj/project.xcworkspace/xcuserdata/capezzbr.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loganwright/SimpleCam/a0b77b2e19e8e161943cb929d1b1be40fb50dc9d/SimpleCam.xcodeproj/project.xcworkspace/xcuserdata/capezzbr.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /SimpleCam.xcodeproj/project.xcworkspace/xcuserdata/loganwright.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loganwright/SimpleCam/a0b77b2e19e8e161943cb929d1b1be40fb50dc9d/SimpleCam.xcodeproj/project.xcworkspace/xcuserdata/loganwright.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /SimpleCam.xcodeproj/xcuserdata/capezzbr.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /SimpleCam.xcodeproj/xcuserdata/capezzbr.xcuserdatad/xcschemes/SimpleCam.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 61 | 62 | 68 | 69 | 70 | 71 | 72 | 73 | 79 | 80 | 86 | 87 | 88 | 89 | 91 | 92 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /SimpleCam.xcodeproj/xcuserdata/capezzbr.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | SimpleCam.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 8058D4E118E9C72F0031A3B1 16 | 17 | primary 18 | 19 | 20 | 8058D4FC18E9C72F0031A3B1 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /SimpleCam.xcodeproj/xcuserdata/loganwright.xcuserdatad/xcschemes/SimpleCam.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 61 | 62 | 68 | 69 | 70 | 71 | 72 | 73 | 79 | 80 | 86 | 87 | 88 | 89 | 91 | 92 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /SimpleCam.xcodeproj/xcuserdata/loganwright.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | SimpleCam.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 8058D4E118E9C72F0031A3B1 16 | 17 | primary 18 | 19 | 20 | 8058D4FC18E9C72F0031A3B1 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /SimpleCam/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // SimpleCam 4 | // 5 | // Created by Logan Wright on 3/31/14. 6 | // Copyright (c) 2014 Logan Wright. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /SimpleCam/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // SimpleCam 4 | // 5 | // Created by Logan Wright on 3/31/14. 6 | // Copyright (c) 2014 Logan Wright. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "RootViewController.h" 11 | 12 | @implementation AppDelegate 13 | 14 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 15 | { 16 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 17 | // Override point for customization after application launch. 18 | self.window.backgroundColor = [UIColor whiteColor]; 19 | [self.window makeKeyAndVisible]; 20 | 21 | [self.window setRootViewController:[[RootViewController alloc]init]]; 22 | return YES; 23 | } 24 | 25 | - (void)applicationWillResignActive:(UIApplication *)application 26 | { 27 | // 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. 28 | // 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. 29 | } 30 | 31 | - (void)applicationDidEnterBackground:(UIApplication *)application 32 | { 33 | // 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. 34 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 35 | } 36 | 37 | - (void)applicationWillEnterForeground:(UIApplication *)application 38 | { 39 | // 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. 40 | } 41 | 42 | - (void)applicationDidBecomeActive:(UIApplication *)application 43 | { 44 | // 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. 45 | } 46 | 47 | - (void)applicationWillTerminate:(UIApplication *)application 48 | { 49 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 50 | } 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /SimpleCam/Images.xcassets/AppIcon.appiconset/120b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loganwright/SimpleCam/a0b77b2e19e8e161943cb929d1b1be40fb50dc9d/SimpleCam/Images.xcassets/AppIcon.appiconset/120b.png -------------------------------------------------------------------------------- /SimpleCam/Images.xcassets/AppIcon.appiconset/58b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loganwright/SimpleCam/a0b77b2e19e8e161943cb929d1b1be40fb50dc9d/SimpleCam/Images.xcassets/AppIcon.appiconset/58b.png -------------------------------------------------------------------------------- /SimpleCam/Images.xcassets/AppIcon.appiconset/80b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loganwright/SimpleCam/a0b77b2e19e8e161943cb929d1b1be40fb50dc9d/SimpleCam/Images.xcassets/AppIcon.appiconset/80b.png -------------------------------------------------------------------------------- /SimpleCam/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "29x29", 5 | "idiom" : "iphone", 6 | "filename" : "58b.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "40x40", 11 | "idiom" : "iphone", 12 | "filename" : "80b.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "60x60", 17 | "idiom" : "iphone", 18 | "filename" : "120b.png", 19 | "scale" : "2x" 20 | } 21 | ], 22 | "info" : { 23 | "version" : 1, 24 | "author" : "xcode" 25 | } 26 | } -------------------------------------------------------------------------------- /SimpleCam/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "scale" : "2x" 9 | }, 10 | { 11 | "orientation" : "portrait", 12 | "idiom" : "iphone", 13 | "subtype" : "retina4", 14 | "extent" : "full-screen", 15 | "minimum-system-version" : "7.0", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /SimpleCam/Images/Attribution_PixelLove.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loganwright/SimpleCam/a0b77b2e19e8e161943cb929d1b1be40fb50dc9d/SimpleCam/Images/Attribution_PixelLove.png -------------------------------------------------------------------------------- /SimpleCam/Images/SimpleCamCover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loganwright/SimpleCam/a0b77b2e19e8e161943cb929d1b1be40fb50dc9d/SimpleCam/Images/SimpleCamCover.png -------------------------------------------------------------------------------- /SimpleCam/Images/landscape_Camera.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loganwright/SimpleCam/a0b77b2e19e8e161943cb929d1b1be40fb50dc9d/SimpleCam/Images/landscape_Camera.png -------------------------------------------------------------------------------- /SimpleCam/Images/landscape_Preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loganwright/SimpleCam/a0b77b2e19e8e161943cb929d1b1be40fb50dc9d/SimpleCam/Images/landscape_Preview.png -------------------------------------------------------------------------------- /SimpleCam/Images/landscape_RotatedPreview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loganwright/SimpleCam/a0b77b2e19e8e161943cb929d1b1be40fb50dc9d/SimpleCam/Images/landscape_RotatedPreview.png -------------------------------------------------------------------------------- /SimpleCam/Images/placeit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loganwright/SimpleCam/a0b77b2e19e8e161943cb929d1b1be40fb50dc9d/SimpleCam/Images/placeit.png -------------------------------------------------------------------------------- /SimpleCam/Images/portrait_Camera.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loganwright/SimpleCam/a0b77b2e19e8e161943cb929d1b1be40fb50dc9d/SimpleCam/Images/portrait_Camera.png -------------------------------------------------------------------------------- /SimpleCam/Images/portrait_Preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loganwright/SimpleCam/a0b77b2e19e8e161943cb929d1b1be40fb50dc9d/SimpleCam/Images/portrait_Preview.png -------------------------------------------------------------------------------- /SimpleCam/Images/portrait_RotatedPreview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loganwright/SimpleCam/a0b77b2e19e8e161943cb929d1b1be40fb50dc9d/SimpleCam/Images/portrait_RotatedPreview.png -------------------------------------------------------------------------------- /SimpleCam/Images/shutter@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loganwright/SimpleCam/a0b77b2e19e8e161943cb929d1b1be40fb50dc9d/SimpleCam/Images/shutter@2x.png -------------------------------------------------------------------------------- /SimpleCam/RootViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // RootViewController.h 3 | // SimpleCam 4 | // 5 | // Created by Logan Wright on 3/31/14. 6 | // Copyright (c) 2014 Logan Wright. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "SimpleCam.h" 11 | 12 | @interface RootViewController : UIViewController 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /SimpleCam/RootViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // RootViewController.m 3 | // SimpleCam 4 | // 5 | // Created by Logan Wright on 3/31/14. 6 | // Copyright (c) 2014 Logan Wright. All rights reserved. 7 | // 8 | 9 | #import "RootViewController.h" 10 | 11 | @interface RootViewController () 12 | 13 | @property (strong, nonatomic) UIImageView * imgView; 14 | @property (strong, nonatomic) UILabel * tapLabel; 15 | @property (nonatomic,strong) SimpleCam *simpleCam; 16 | @property (nonatomic) BOOL takePhotoImmediately; 17 | 18 | @end 19 | 20 | @implementation RootViewController 21 | 22 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 23 | { 24 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 25 | if (self) { 26 | // Custom initialization 27 | } 28 | return self; 29 | } 30 | 31 | - (void)viewDidLoad 32 | { 33 | [super viewDidLoad]; 34 | // Do any additional setup after loading the view. 35 | 36 | _imgView = [UIImageView new]; 37 | _imgView.bounds = CGRectMake(0, 0, 200, 300); 38 | _imgView.center = self.view.center; 39 | _imgView.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin; 40 | _imgView.contentMode = UIViewContentModeScaleAspectFit; 41 | [self.view addSubview:_imgView]; 42 | 43 | _tapLabel = [UILabel new]; 44 | _tapLabel.bounds = CGRectMake(0, 0, 200, 100); 45 | _tapLabel.text = @"TAP TO TAKE PHOTO"; 46 | _tapLabel.textAlignment = NSTextAlignmentCenter; 47 | _tapLabel.center = self.view.center; 48 | _tapLabel.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin; 49 | [self.view addSubview:_tapLabel]; 50 | 51 | UITapGestureRecognizer * tap = [UITapGestureRecognizer new]; 52 | [tap addTarget:self action:@selector(handleTap:)]; 53 | [self.view addGestureRecognizer:tap]; 54 | } 55 | 56 | #pragma mark ACTIONSHEET 57 | 58 | - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { 59 | self.takePhotoImmediately = NO; 60 | switch (buttonIndex) { 61 | case 0: // default 62 | { 63 | SimpleCam * simpleCam = [SimpleCam new]; 64 | simpleCam.delegate= self; 65 | 66 | [self presentViewController:simpleCam animated:YES completion:nil]; 67 | } 68 | break; 69 | 70 | case 1: // take photo immediately 71 | { 72 | self.takePhotoImmediately = YES; 73 | 74 | SimpleCam * simpleCam = [SimpleCam new]; 75 | simpleCam.delegate= self; 76 | // [simpleCam setHideCaptureButton:YES]; 77 | // [simpleCam setHideBackButton:YES]; 78 | simpleCam.hideAllControls = YES; 79 | [simpleCam setDisablePhotoPreview:YES]; 80 | [self presentViewController:simpleCam animated:YES completion:nil]; 81 | } 82 | break; 83 | 84 | case 2: // overlay 85 | { 86 | self.simpleCam = [SimpleCam new]; 87 | self.simpleCam.delegate= self; 88 | [self.simpleCam setHideAllControls:YES]; 89 | [self.simpleCam setDisablePhotoPreview:YES]; 90 | 91 | [self.simpleCam setEnableZoom:YES]; 92 | [self.simpleCam setEnableCameraCaptureAnimation:YES]; 93 | 94 | CGRect frame; 95 | frame.size = CGSizeMake(self.view.frame.size.width, 120); 96 | frame.origin.x = 0; 97 | frame.origin.y = self.view.frame.size.height -frame.size.height; 98 | UIView *overlayView = [[UIView alloc] initWithFrame:frame]; 99 | overlayView.backgroundColor = [UIColor blackColor]; 100 | overlayView.alpha = 0.3; 101 | overlayView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin; 102 | 103 | UIImage *image = [UIImage imageNamed:@"shutter"]; 104 | frame.size = image.size; 105 | frame.origin.x = (overlayView.frame.size.width -frame.size.width)/2; 106 | frame.origin.y = (overlayView.frame.size.height -frame.size.height)/2; 107 | UIButton *button = [[UIButton alloc] initWithFrame:frame]; 108 | [button setImage:image forState:UIControlStateNormal]; 109 | [button addTarget:self action:@selector(actionPhoto) forControlEvents:UIControlEventTouchUpInside]; 110 | button.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin; 111 | [overlayView addSubview:button]; 112 | [self.simpleCam.view addSubview:overlayView]; 113 | 114 | [self presentViewController:self.simpleCam animated:YES completion:nil]; 115 | } 116 | break; 117 | 118 | default: 119 | break; 120 | } 121 | } 122 | 123 | #pragma mark PRIVATE 124 | 125 | - (void)actionPhoto 126 | { 127 | [self.simpleCam capturePhoto]; 128 | } 129 | 130 | #pragma mark TAP RECOGNIZER 131 | 132 | - (void) handleTap:(UITapGestureRecognizer *)tap { 133 | 134 | UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"SimpleCam Options" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Default", @"Take Photo Immediately", @"Custom", nil]; 135 | [sheet showInView:self.view]; 136 | 137 | 138 | } 139 | 140 | #pragma mark SIMPLE CAM DELEGATE 141 | 142 | - (void) simpleCam:(SimpleCam *)simpleCam didFinishWithImage:(UIImage *)image { 143 | 144 | if (image) { 145 | // simple cam finished with image 146 | 147 | _imgView.image = image; 148 | //_tapLabel.hidden = NO; 149 | } 150 | else { 151 | // simple cam finished w/o image 152 | 153 | _imgView.image = nil; 154 | //_tapLabel.hidden = NO; 155 | } 156 | 157 | // Close simpleCam - use this as opposed to 'dismissViewController' otherwise, the captureSession may not close properly and may result in memory leaks. 158 | [simpleCam closeWithCompletion:^{ 159 | NSLog(@"SimpleCam is done closing ... "); 160 | }]; 161 | } 162 | 163 | - (void) simpleCamDidLoadCameraIntoView:(SimpleCam *)simpleCam { 164 | NSLog(@"Camera loaded ... "); 165 | 166 | if (self.takePhotoImmediately) { 167 | [simpleCam capturePhoto]; 168 | } 169 | } 170 | 171 | - (void) simpleCamNotAuthorizedForCameraUse:(SimpleCam *)simpleCam { 172 | [simpleCam closeWithCompletion:^{ 173 | NSLog(@"SimpleCam is done closing ... Not Authorized"); 174 | }]; 175 | } 176 | 177 | @end 178 | -------------------------------------------------------------------------------- /SimpleCam/SimpleCam-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | lowri.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 0.1.5 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 0.1.5 25 | LSRequiresIPhoneOS 26 | 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /SimpleCam/SimpleCam-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #import 8 | 9 | #ifndef __IPHONE_3_0 10 | #warning "This project uses features only available in iOS SDK 3.0 and later." 11 | #endif 12 | 13 | #ifdef __OBJC__ 14 | #import 15 | #import 16 | #endif 17 | -------------------------------------------------------------------------------- /SimpleCam/SimpleCam/Icons/CameraRotate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loganwright/SimpleCam/a0b77b2e19e8e161943cb929d1b1be40fb50dc9d/SimpleCam/SimpleCam/Icons/CameraRotate.png -------------------------------------------------------------------------------- /SimpleCam/SimpleCam/Icons/Download.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loganwright/SimpleCam/a0b77b2e19e8e161943cb929d1b1be40fb50dc9d/SimpleCam/SimpleCam/Icons/Download.png -------------------------------------------------------------------------------- /SimpleCam/SimpleCam/Icons/Lightening.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loganwright/SimpleCam/a0b77b2e19e8e161943cb929d1b1be40fb50dc9d/SimpleCam/SimpleCam/Icons/Lightening.png -------------------------------------------------------------------------------- /SimpleCam/SimpleCam/Icons/Previous.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loganwright/SimpleCam/a0b77b2e19e8e161943cb929d1b1be40fb50dc9d/SimpleCam/SimpleCam/Icons/Previous.png -------------------------------------------------------------------------------- /SimpleCam/SimpleCam/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Mozilla Public License Version 2.0 2 | ================================== 3 | 4 | 1. Definitions 5 | -------------- 6 | 7 | 1.1. "Contributor" 8 | means each individual or legal entity that creates, contributes to 9 | the creation of, or owns Covered Software. 10 | 11 | 1.2. "Contributor Version" 12 | means the combination of the Contributions of others (if any) used 13 | by a Contributor and that particular Contributor's Contribution. 14 | 15 | 1.3. "Contribution" 16 | means Covered Software of a particular Contributor. 17 | 18 | 1.4. "Covered Software" 19 | means Source Code Form to which the initial Contributor has attached 20 | the notice in Exhibit A, the Executable Form of such Source Code 21 | Form, and Modifications of such Source Code Form, in each case 22 | including portions thereof. 23 | 24 | 1.5. "Incompatible With Secondary Licenses" 25 | means 26 | 27 | (a) that the initial Contributor has attached the notice described 28 | in Exhibit B to the Covered Software; or 29 | 30 | (b) that the Covered Software was made available under the terms of 31 | version 1.1 or earlier of the License, but not also under the 32 | terms of a Secondary License. 33 | 34 | 1.6. "Executable Form" 35 | means any form of the work other than Source Code Form. 36 | 37 | 1.7. "Larger Work" 38 | means a work that combines Covered Software with other material, in 39 | a separate file or files, that is not Covered Software. 40 | 41 | 1.8. "License" 42 | means this document. 43 | 44 | 1.9. "Licensable" 45 | means having the right to grant, to the maximum extent possible, 46 | whether at the time of the initial grant or subsequently, any and 47 | all of the rights conveyed by this License. 48 | 49 | 1.10. "Modifications" 50 | means any of the following: 51 | 52 | (a) any file in Source Code Form that results from an addition to, 53 | deletion from, or modification of the contents of Covered 54 | Software; or 55 | 56 | (b) any new file in Source Code Form that contains any Covered 57 | Software. 58 | 59 | 1.11. "Patent Claims" of a Contributor 60 | means any patent claim(s), including without limitation, method, 61 | process, and apparatus claims, in any patent Licensable by such 62 | Contributor that would be infringed, but for the grant of the 63 | License, by the making, using, selling, offering for sale, having 64 | made, import, or transfer of either its Contributions or its 65 | Contributor Version. 66 | 67 | 1.12. "Secondary License" 68 | means either the GNU General Public License, Version 2.0, the GNU 69 | Lesser General Public License, Version 2.1, the GNU Affero General 70 | Public License, Version 3.0, or any later versions of those 71 | licenses. 72 | 73 | 1.13. "Source Code Form" 74 | means the form of the work preferred for making modifications. 75 | 76 | 1.14. "You" (or "Your") 77 | means an individual or a legal entity exercising rights under this 78 | License. For legal entities, "You" includes any entity that 79 | controls, is controlled by, or is under common control with You. For 80 | purposes of this definition, "control" means (a) the power, direct 81 | or indirect, to cause the direction or management of such entity, 82 | whether by contract or otherwise, or (b) ownership of more than 83 | fifty percent (50%) of the outstanding shares or beneficial 84 | ownership of such entity. 85 | 86 | 2. License Grants and Conditions 87 | -------------------------------- 88 | 89 | 2.1. Grants 90 | 91 | Each Contributor hereby grants You a world-wide, royalty-free, 92 | non-exclusive license: 93 | 94 | (a) under intellectual property rights (other than patent or trademark) 95 | Licensable by such Contributor to use, reproduce, make available, 96 | modify, display, perform, distribute, and otherwise exploit its 97 | Contributions, either on an unmodified basis, with Modifications, or 98 | as part of a Larger Work; and 99 | 100 | (b) under Patent Claims of such Contributor to make, use, sell, offer 101 | for sale, have made, import, and otherwise transfer either its 102 | Contributions or its Contributor Version. 103 | 104 | 2.2. Effective Date 105 | 106 | The licenses granted in Section 2.1 with respect to any Contribution 107 | become effective for each Contribution on the date the Contributor first 108 | distributes such Contribution. 109 | 110 | 2.3. Limitations on Grant Scope 111 | 112 | The licenses granted in this Section 2 are the only rights granted under 113 | this License. No additional rights or licenses will be implied from the 114 | distribution or licensing of Covered Software under this License. 115 | Notwithstanding Section 2.1(b) above, no patent license is granted by a 116 | Contributor: 117 | 118 | (a) for any code that a Contributor has removed from Covered Software; 119 | or 120 | 121 | (b) for infringements caused by: (i) Your and any other third party's 122 | modifications of Covered Software, or (ii) the combination of its 123 | Contributions with other software (except as part of its Contributor 124 | Version); or 125 | 126 | (c) under Patent Claims infringed by Covered Software in the absence of 127 | its Contributions. 128 | 129 | This License does not grant any rights in the trademarks, service marks, 130 | or logos of any Contributor (except as may be necessary to comply with 131 | the notice requirements in Section 3.4). 132 | 133 | 2.4. Subsequent Licenses 134 | 135 | No Contributor makes additional grants as a result of Your choice to 136 | distribute the Covered Software under a subsequent version of this 137 | License (see Section 10.2) or under the terms of a Secondary License (if 138 | permitted under the terms of Section 3.3). 139 | 140 | 2.5. Representation 141 | 142 | Each Contributor represents that the Contributor believes its 143 | Contributions are its original creation(s) or it has sufficient rights 144 | to grant the rights to its Contributions conveyed by this License. 145 | 146 | 2.6. Fair Use 147 | 148 | This License is not intended to limit any rights You have under 149 | applicable copyright doctrines of fair use, fair dealing, or other 150 | equivalents. 151 | 152 | 2.7. Conditions 153 | 154 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted 155 | in Section 2.1. 156 | 157 | 3. Responsibilities 158 | ------------------- 159 | 160 | 3.1. Distribution of Source Form 161 | 162 | All distribution of Covered Software in Source Code Form, including any 163 | Modifications that You create or to which You contribute, must be under 164 | the terms of this License. You must inform recipients that the Source 165 | Code Form of the Covered Software is governed by the terms of this 166 | License, and how they can obtain a copy of this License. You may not 167 | attempt to alter or restrict the recipients' rights in the Source Code 168 | Form. 169 | 170 | 3.2. Distribution of Executable Form 171 | 172 | If You distribute Covered Software in Executable Form then: 173 | 174 | (a) such Covered Software must also be made available in Source Code 175 | Form, as described in Section 3.1, and You must inform recipients of 176 | the Executable Form how they can obtain a copy of such Source Code 177 | Form by reasonable means in a timely manner, at a charge no more 178 | than the cost of distribution to the recipient; and 179 | 180 | (b) You may distribute such Executable Form under the terms of this 181 | License, or sublicense it under different terms, provided that the 182 | license for the Executable Form does not attempt to limit or alter 183 | the recipients' rights in the Source Code Form under this License. 184 | 185 | 3.3. Distribution of a Larger Work 186 | 187 | You may create and distribute a Larger Work under terms of Your choice, 188 | provided that You also comply with the requirements of this License for 189 | the Covered Software. If the Larger Work is a combination of Covered 190 | Software with a work governed by one or more Secondary Licenses, and the 191 | Covered Software is not Incompatible With Secondary Licenses, this 192 | License permits You to additionally distribute such Covered Software 193 | under the terms of such Secondary License(s), so that the recipient of 194 | the Larger Work may, at their option, further distribute the Covered 195 | Software under the terms of either this License or such Secondary 196 | License(s). 197 | 198 | 3.4. Notices 199 | 200 | You may not remove or alter the substance of any license notices 201 | (including copyright notices, patent notices, disclaimers of warranty, 202 | or limitations of liability) contained within the Source Code Form of 203 | the Covered Software, except that You may alter any license notices to 204 | the extent required to remedy known factual inaccuracies. 205 | 206 | 3.5. Application of Additional Terms 207 | 208 | You may choose to offer, and to charge a fee for, warranty, support, 209 | indemnity or liability obligations to one or more recipients of Covered 210 | Software. However, You may do so only on Your own behalf, and not on 211 | behalf of any Contributor. You must make it absolutely clear that any 212 | such warranty, support, indemnity, or liability obligation is offered by 213 | You alone, and You hereby agree to indemnify every Contributor for any 214 | liability incurred by such Contributor as a result of warranty, support, 215 | indemnity or liability terms You offer. You may include additional 216 | disclaimers of warranty and limitations of liability specific to any 217 | jurisdiction. 218 | 219 | 4. Inability to Comply Due to Statute or Regulation 220 | --------------------------------------------------- 221 | 222 | If it is impossible for You to comply with any of the terms of this 223 | License with respect to some or all of the Covered Software due to 224 | statute, judicial order, or regulation then You must: (a) comply with 225 | the terms of this License to the maximum extent possible; and (b) 226 | describe the limitations and the code they affect. Such description must 227 | be placed in a text file included with all distributions of the Covered 228 | Software under this License. Except to the extent prohibited by statute 229 | or regulation, such description must be sufficiently detailed for a 230 | recipient of ordinary skill to be able to understand it. 231 | 232 | 5. Termination 233 | -------------- 234 | 235 | 5.1. The rights granted under this License will terminate automatically 236 | if You fail to comply with any of its terms. However, if You become 237 | compliant, then the rights granted under this License from a particular 238 | Contributor are reinstated (a) provisionally, unless and until such 239 | Contributor explicitly and finally terminates Your grants, and (b) on an 240 | ongoing basis, if such Contributor fails to notify You of the 241 | non-compliance by some reasonable means prior to 60 days after You have 242 | come back into compliance. Moreover, Your grants from a particular 243 | Contributor are reinstated on an ongoing basis if such Contributor 244 | notifies You of the non-compliance by some reasonable means, this is the 245 | first time You have received notice of non-compliance with this License 246 | from such Contributor, and You become compliant prior to 30 days after 247 | Your receipt of the notice. 248 | 249 | 5.2. If You initiate litigation against any entity by asserting a patent 250 | infringement claim (excluding declaratory judgment actions, 251 | counter-claims, and cross-claims) alleging that a Contributor Version 252 | directly or indirectly infringes any patent, then the rights granted to 253 | You by any and all Contributors for the Covered Software under Section 254 | 2.1 of this License shall terminate. 255 | 256 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all 257 | end user license agreements (excluding distributors and resellers) which 258 | have been validly granted by You or Your distributors under this License 259 | prior to termination shall survive termination. 260 | 261 | ************************************************************************ 262 | * * 263 | * 6. Disclaimer of Warranty * 264 | * ------------------------- * 265 | * * 266 | * Covered Software is provided under this License on an "as is" * 267 | * basis, without warranty of any kind, either expressed, implied, or * 268 | * statutory, including, without limitation, warranties that the * 269 | * Covered Software is free of defects, merchantable, fit for a * 270 | * particular purpose or non-infringing. The entire risk as to the * 271 | * quality and performance of the Covered Software is with You. * 272 | * Should any Covered Software prove defective in any respect, You * 273 | * (not any Contributor) assume the cost of any necessary servicing, * 274 | * repair, or correction. This disclaimer of warranty constitutes an * 275 | * essential part of this License. No use of any Covered Software is * 276 | * authorized under this License except under this disclaimer. * 277 | * * 278 | ************************************************************************ 279 | 280 | ************************************************************************ 281 | * * 282 | * 7. Limitation of Liability * 283 | * -------------------------- * 284 | * * 285 | * Under no circumstances and under no legal theory, whether tort * 286 | * (including negligence), contract, or otherwise, shall any * 287 | * Contributor, or anyone who distributes Covered Software as * 288 | * permitted above, be liable to You for any direct, indirect, * 289 | * special, incidental, or consequential damages of any character * 290 | * including, without limitation, damages for lost profits, loss of * 291 | * goodwill, work stoppage, computer failure or malfunction, or any * 292 | * and all other commercial damages or losses, even if such party * 293 | * shall have been informed of the possibility of such damages. This * 294 | * limitation of liability shall not apply to liability for death or * 295 | * personal injury resulting from such party's negligence to the * 296 | * extent applicable law prohibits such limitation. Some * 297 | * jurisdictions do not allow the exclusion or limitation of * 298 | * incidental or consequential damages, so this exclusion and * 299 | * limitation may not apply to You. * 300 | * * 301 | ************************************************************************ 302 | 303 | 8. Litigation 304 | ------------- 305 | 306 | Any litigation relating to this License may be brought only in the 307 | courts of a jurisdiction where the defendant maintains its principal 308 | place of business and such litigation shall be governed by laws of that 309 | jurisdiction, without reference to its conflict-of-law provisions. 310 | Nothing in this Section shall prevent a party's ability to bring 311 | cross-claims or counter-claims. 312 | 313 | 9. Miscellaneous 314 | ---------------- 315 | 316 | This License represents the complete agreement concerning the subject 317 | matter hereof. If any provision of this License is held to be 318 | unenforceable, such provision shall be reformed only to the extent 319 | necessary to make it enforceable. Any law or regulation which provides 320 | that the language of a contract shall be construed against the drafter 321 | shall not be used to construe this License against a Contributor. 322 | 323 | 10. Versions of the License 324 | --------------------------- 325 | 326 | 10.1. New Versions 327 | 328 | Mozilla Foundation is the license steward. Except as provided in Section 329 | 10.3, no one other than the license steward has the right to modify or 330 | publish new versions of this License. Each version will be given a 331 | distinguishing version number. 332 | 333 | 10.2. Effect of New Versions 334 | 335 | You may distribute the Covered Software under the terms of the version 336 | of the License under which You originally received the Covered Software, 337 | or under the terms of any subsequent version published by the license 338 | steward. 339 | 340 | 10.3. Modified Versions 341 | 342 | If you create software not governed by this License, and you want to 343 | create a new license for such software, you may create and use a 344 | modified version of this License if you rename the license and remove 345 | any references to the name of the license steward (except to note that 346 | such modified license differs from this License). 347 | 348 | 10.4. Distributing Source Code Form that is Incompatible With Secondary 349 | Licenses 350 | 351 | If You choose to distribute Source Code Form that is Incompatible With 352 | Secondary Licenses under the terms of this version of the License, the 353 | notice described in Exhibit B of this License must be attached. 354 | 355 | Exhibit A - Source Code Form License Notice 356 | ------------------------------------------- 357 | 358 | This Source Code Form is subject to the terms of the Mozilla Public 359 | License, v. 2.0. If a copy of the MPL was not distributed with this 360 | file, You can obtain one at http://mozilla.org/MPL/2.0/. 361 | 362 | If it is not possible or desirable to put the notice in a particular 363 | file, then You may include the notice in a location (such as a LICENSE 364 | file in a relevant directory) where a recipient would be likely to look 365 | for such a notice. 366 | 367 | You may add additional accurate notices of copyright ownership. 368 | 369 | Exhibit B - "Incompatible With Secondary Licenses" Notice 370 | --------------------------------------------------------- 371 | 372 | This Source Code Form is "Incompatible With Secondary Licenses", as 373 | defined by the Mozilla Public License, v. 2.0. -------------------------------------------------------------------------------- /SimpleCam/SimpleCam/SimpleCam.h: -------------------------------------------------------------------------------- 1 | // 2 | // SimpleCam.h 3 | // SimpleCam 4 | // 5 | // Created by Logan Wright on 2/1/14. 6 | // Copyright (c) 2014 Logan Wright. All rights reserved. 7 | // 8 | // Mozilla Public License v2.0 9 | // 10 | // ** 11 | // 12 | // PLEASE FAMILIARIZE YOURSELF WITH THE ----- Mozilla Public License v2.0 13 | // 14 | // ** 15 | // 16 | // Attribution is satisfied by acknowledging the use of SimpleCam, 17 | // or its creation by Logan Wright 18 | // 19 | // ** 20 | // 21 | // You can use, modify and redistribute this code in your product, 22 | // but to satisfy the requirements of Mozilla Public License v2.0, 23 | // it is required to provide the source code for any fixes you make to it. 24 | // 25 | // ** 26 | // 27 | // Covered Software is provided under this License on an “as is” basis, without warranty of any 28 | // kind, either expressed, implied, or statutory, including, without limitation, warranties that 29 | // the Covered Software is free of defects, merchantable, fit for a particular purpose or non- 30 | // infringing. The entire risk as to the quality and performance of the Covered Software is with 31 | // You. Should any Covered Software prove defective in any respect, You (not any Contributor) 32 | // assume the cost of any necessary servicing, repair, or correction. This disclaimer of 33 | // warranty constitutes an essential part of this License. No use of any Covered Software is 34 | // authorized under this License except under this disclaimer. 35 | // 36 | // ** 37 | // 38 | 39 | /* This Source Code Form is subject to the terms of the Mozilla Public 40 | * License, v. 2.0. If a copy of the MPL was not distributed with this 41 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 42 | 43 | #import 44 | #import 45 | 46 | @class SimpleCam; 47 | 48 | @protocol SimpleCamDelegate 49 | 50 | @required 51 | 52 | - (void) simpleCamNotAuthorizedForCameraUse:(SimpleCam *)simpleCam; 53 | 54 | /*! 55 | Called when the user is done with SimpleCam. If image is nil, user backed out w/o image. 56 | */ 57 | - (void) simpleCam:(SimpleCam *)simpleCam didFinishWithImage:(UIImage *)image; 58 | 59 | @optional 60 | 61 | /*! 62 | Called when the camera is successfully loaded into the view. 63 | */ 64 | - (void) simpleCamDidLoadCameraIntoView:(SimpleCam *)simpleCam; 65 | 66 | @end 67 | 68 | @interface SimpleCam : UIViewController 69 | 70 | /*! 71 | Must adhere to SimpleCamDelegate protocol 72 | */ 73 | @property (retain, nonatomic) id delegate; 74 | 75 | /*! 76 | Used if you'd like your pictures cropped to squareMode - defaults to NO (beta) 77 | */ 78 | @property BOOL isSquareMode; 79 | 80 | /*! 81 | Allow to hide all controls (set to YES to show custom controls) 82 | */ 83 | @property (nonatomic) BOOL hideAllControls; 84 | /*! 85 | Allow to hide the capture button. You can take programmaticaly photo using method 'capturePhoto' 86 | */ 87 | @property (nonatomic) BOOL hideCaptureButton; 88 | /*! 89 | Allow to hide the back button. Used if you want to programmatically control the view flow 90 | */ 91 | @property (nonatomic) BOOL hideBackButton; 92 | 93 | /*! 94 | Allow pinch-to-zoom function for software "zoom" 95 | */ 96 | @property (nonatomic) BOOL enableZoom; 97 | /*! 98 | "Flash" the screen when a photo is taken (helps visually represent the photo has been taken successfully) 99 | */ 100 | @property (nonatomic) BOOL enableCameraCaptureAnimation; 101 | 102 | /*! 103 | Don't show the preview phase of the photo acquisition 104 | */ 105 | @property (nonatomic) BOOL disablePhotoPreview; 106 | /*! 107 | Control animation duration 108 | */ 109 | @property (nonatomic) float controlAnimateDuration; 110 | 111 | /*! 112 | Use this to close SimpleCam - Otherwise, the captureSession may not close properly and may result in memory leaks. 113 | */ 114 | - (void) closeWithCompletion:(void (^)(void))completion; 115 | 116 | /*! 117 | Use this method for programmatically acquire a photo 118 | */ 119 | - (void) capturePhoto; 120 | 121 | 122 | @end 123 | -------------------------------------------------------------------------------- /SimpleCam/SimpleCam/SimpleCam.m: -------------------------------------------------------------------------------- 1 | // 2 | // SimpleCam.m 3 | // SimpleCam 4 | // 5 | // Created by Logan Wright on 2/1/14. 6 | // Copyright (c) 2014 Logan Wright. All rights reserved. 7 | // 8 | // Mozilla Public License v2.0 9 | // 10 | // ** 11 | // 12 | // PLEASE FAMILIARIZE YOURSELF WITH THE ----- Mozilla Public License v2.0 13 | // 14 | // ** 15 | // 16 | // Attribution is satisfied by acknowledging the use of SimpleCam, 17 | // or its creation by Logan Wright 18 | // 19 | // ** 20 | // 21 | // You can use, modify and redistribute this code in your product, 22 | // but to satisfy the requirements of Mozilla Public License v2.0, 23 | // it is required to provide the source code for any fixes you make to it. 24 | // 25 | // ** 26 | // 27 | // Covered Software is provided under this License on an “as is” basis, without warranty of any 28 | // kind, either expressed, implied, or statutory, including, without limitation, warranties that 29 | // the Covered Software is free of defects, merchantable, fit for a particular purpose or non- 30 | // infringing. The entire risk as to the quality and performance of the Covered Software is with 31 | // You. Should any Covered Software prove defective in any respect, You (not any Contributor) 32 | // assume the cost of any necessary servicing, repair, or correction. This disclaimer of 33 | // warranty constitutes an essential part of this License. No use of any Covered Software is 34 | // authorized under this License except under this disclaimer. 35 | // 36 | // ** 37 | // 38 | 39 | /* This Source Code Form is subject to the terms of the Mozilla Public 40 | * License, v. 2.0. If a copy of the MPL was not distributed with this 41 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 42 | 43 | static CGFloat optionAvailableAlpha = 0.6; 44 | static CGFloat optionUnavailableAlpha = 0.2; 45 | 46 | #import "SimpleCam.h" 47 | 48 | @interface SimpleCam () 49 | { 50 | // Measurements 51 | CGFloat screenWidth; 52 | CGFloat screenHeight; 53 | CGFloat topX; 54 | CGFloat topY; 55 | 56 | // Zoom scale 57 | CGFloat scale; 58 | 59 | // Resize Toggles 60 | BOOL isImageResized; 61 | BOOL isSaveWaitingForResizedImage; 62 | BOOL isRotateWaitingForResizedImage; 63 | 64 | // Capture Toggle 65 | BOOL isCapturingImage; 66 | 67 | // Animate a "flash" on-screen when a photo is taken 68 | UIView *cameraCaptureFlashAnimation; 69 | } 70 | 71 | // Used to cover animation flicker during rotation 72 | @property (strong, nonatomic) UIView * rotationCover; 73 | 74 | // Square Border 75 | @property (strong, nonatomic) UIView * squareV; 76 | 77 | // Controls 78 | @property (strong, nonatomic) UIButton * backBtn; 79 | @property (strong, nonatomic) UIButton * captureBtn; 80 | @property (strong, nonatomic) UIButton * flashBtn; 81 | @property (strong, nonatomic) UIButton * switchCameraBtn; 82 | @property (strong, nonatomic) UIButton * saveBtn; 83 | 84 | // AVFoundation Properties 85 | @property (strong, nonatomic) AVCaptureSession * mySesh; 86 | @property (strong, nonatomic) AVCaptureStillImageOutput *stillImageOutput; 87 | @property (strong, nonatomic) AVCaptureDevice * myDevice; 88 | @property (strong, nonatomic) AVCaptureVideoPreviewLayer * captureVideoPreviewLayer; 89 | 90 | // View Properties 91 | @property (strong, nonatomic) UIView * imageStreamV; 92 | @property (strong, nonatomic) UIImageView * capturedImageV; 93 | 94 | @end 95 | 96 | @implementation SimpleCam; 97 | 98 | @synthesize hideAllControls = _hideAllControls, hideBackButton = _hideBackButton, hideCaptureButton = _hideCaptureButton; 99 | @synthesize enableZoom = _enableZoom, enableCameraCaptureAnimation = _enableCameraCaptureAnimation; 100 | 101 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { 102 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 103 | if (self) { 104 | 105 | // Custom initialization 106 | self.controlAnimateDuration = 0.25; 107 | } 108 | return self; 109 | } 110 | 111 | 112 | - (void)viewDidLoad { 113 | 114 | [super viewDidLoad]; 115 | 116 | if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_7_1) { 117 | // Pre iOS 8 -- No camera auth required. 118 | [self setup]; 119 | } 120 | else { 121 | // iOS 8 122 | 123 | // Thanks: http://stackoverflow.com/a/24684021/2611971 124 | AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo]; 125 | switch (status) { 126 | case AVAuthorizationStatusAuthorized: 127 | // Do setup early if possible. 128 | [self setup]; 129 | break; 130 | default: 131 | break; 132 | } 133 | 134 | } 135 | 136 | 137 | } 138 | 139 | - (void) viewDidAppear:(BOOL)animated { 140 | 141 | [super viewDidAppear:animated]; 142 | 143 | if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_7_1) { 144 | // Pre iOS 8 -- No camera auth required. 145 | [self animateIntoView]; 146 | } 147 | else { 148 | // iOS 8 149 | AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo]; 150 | switch (status) { 151 | case AVAuthorizationStatusDenied: 152 | case AVAuthorizationStatusRestricted: 153 | NSLog(@"SC: Not authorized, or restricted"); 154 | [self.delegate simpleCamNotAuthorizedForCameraUse:self]; 155 | break; 156 | case AVAuthorizationStatusAuthorized: 157 | [self animateIntoView]; 158 | break; 159 | case AVAuthorizationStatusNotDetermined: { 160 | // not determined 161 | [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) { 162 | dispatch_async(dispatch_get_main_queue(), ^{ 163 | if(granted){ 164 | [self setup]; 165 | [self animateIntoView]; 166 | } else { 167 | [self.delegate simpleCam:self didFinishWithImage:nil]; 168 | } 169 | }); 170 | }]; 171 | } 172 | default: 173 | break; 174 | } 175 | } 176 | } 177 | 178 | - (void) animateIntoView 179 | { 180 | [UIView animateWithDuration:.25 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{ 181 | _imageStreamV.alpha = 1; 182 | _rotationCover.alpha = 1; 183 | } completion:^(BOOL finished) { 184 | if (finished) { 185 | if ([(NSObject *)_delegate respondsToSelector:@selector(simpleCamDidLoadCameraIntoView:)]) { 186 | [_delegate simpleCamDidLoadCameraIntoView:self]; 187 | } 188 | } 189 | }]; 190 | } 191 | 192 | - (void)didReceiveMemoryWarning { 193 | [super didReceiveMemoryWarning]; 194 | NSLog(@"SC: DID RECIEVE MEMORY WARNING"); 195 | // Dispose of any resources that can be recreated. 196 | } 197 | 198 | #pragma mark - Setup 199 | 200 | 201 | - (void) setup { 202 | 203 | self.view.clipsToBounds = NO; 204 | self.view.backgroundColor = [UIColor blackColor]; 205 | 206 | /* 207 | The layout has shifted in iOS 8 causing problems. I realize that this isn't the best solution, so if you're looking at this, feel free to submit a Pull Request. This is an older project. 208 | */ 209 | CGRect screen = [UIScreen mainScreen].bounds; 210 | CGFloat currentWidth = CGRectGetWidth(screen); 211 | CGFloat currentHeight = CGRectGetHeight(screen); 212 | screenWidth = currentWidth < currentHeight ? currentWidth : currentHeight; 213 | screenHeight = currentWidth < currentHeight ? currentHeight : currentWidth; 214 | 215 | if (_imageStreamV == nil) _imageStreamV = [[UIView alloc]init]; 216 | _imageStreamV.alpha = 0; 217 | _imageStreamV.frame = self.view.bounds; 218 | [self.view addSubview:_imageStreamV]; 219 | 220 | if (_capturedImageV == nil) _capturedImageV = [[UIImageView alloc]init]; 221 | _capturedImageV.frame = _imageStreamV.frame; // just to even it out 222 | _capturedImageV.backgroundColor = [UIColor clearColor]; 223 | _capturedImageV.userInteractionEnabled = YES; 224 | _capturedImageV.contentMode = UIViewContentModeScaleAspectFill; 225 | [self.view insertSubview:_capturedImageV aboveSubview:_imageStreamV]; 226 | 227 | // for focus 228 | UITapGestureRecognizer * focusTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapSent:)]; 229 | focusTap.numberOfTapsRequired = 1; 230 | [_capturedImageV addGestureRecognizer:focusTap]; 231 | 232 | // for zoom 233 | if (_enableZoom) { 234 | UIPinchGestureRecognizer * zoomPinch = [[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(pinchToZoom:)]; 235 | [_capturedImageV addGestureRecognizer:zoomPinch]; 236 | } 237 | 238 | // SETTING UP CAM 239 | if (_mySesh == nil) _mySesh = [[AVCaptureSession alloc] init]; 240 | _mySesh.sessionPreset = AVCaptureSessionPresetPhoto; 241 | 242 | _captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:_mySesh]; 243 | _captureVideoPreviewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill; 244 | _captureVideoPreviewLayer.frame = _imageStreamV.layer.bounds; // parent of layer 245 | 246 | [_imageStreamV.layer addSublayer:_captureVideoPreviewLayer]; 247 | 248 | // rear camera: 0 front camera: 1 249 | NSArray *devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]; 250 | if (devices.count==0) { 251 | NSLog(@"SC: No devices found (for example: simulator)"); 252 | return; 253 | } 254 | _myDevice = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo][0]; 255 | 256 | if ([_myDevice isFlashAvailable] && _myDevice.flashActive && [_myDevice lockForConfiguration:nil]) { 257 | //NSLog(@"SC: Turning Flash Off ..."); 258 | _myDevice.flashMode = AVCaptureFlashModeOff; 259 | [_myDevice unlockForConfiguration]; 260 | } 261 | 262 | NSError * error = nil; 263 | AVCaptureDeviceInput * input = [AVCaptureDeviceInput deviceInputWithDevice:_myDevice error:&error]; 264 | 265 | if (!input) { 266 | // Handle the error appropriately. 267 | NSLog(@"SC: ERROR: trying to open camera: %@", error); 268 | [_delegate simpleCam:self didFinishWithImage:_capturedImageV.image]; 269 | } 270 | 271 | [_mySesh addInput:input]; 272 | 273 | _stillImageOutput = [[AVCaptureStillImageOutput alloc] init]; 274 | NSDictionary * outputSettings = [[NSDictionary alloc] initWithObjectsAndKeys: AVVideoCodecJPEG, AVVideoCodecKey, nil]; 275 | [_stillImageOutput setOutputSettings:outputSettings]; 276 | [_mySesh addOutput:_stillImageOutput]; 277 | 278 | [_mySesh startRunning]; 279 | 280 | if (self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft) { 281 | _captureVideoPreviewLayer.connection.videoOrientation = AVCaptureVideoOrientationLandscapeLeft; 282 | } 283 | else if (self.interfaceOrientation == UIInterfaceOrientationLandscapeRight) { 284 | _captureVideoPreviewLayer.connection.videoOrientation = AVCaptureVideoOrientationLandscapeRight; 285 | } 286 | 287 | if (_isSquareMode) { 288 | NSLog(@"SC: isSquareMode"); 289 | _squareV = [[UIView alloc]init]; 290 | _squareV.backgroundColor = [UIColor clearColor]; 291 | _squareV.layer.borderWidth = 4; 292 | _squareV.layer.borderColor = [UIColor colorWithWhite:1 alpha:.8].CGColor; 293 | _squareV.bounds = CGRectMake(0, 0, screenWidth, screenWidth); 294 | _squareV.center = self.view.center; 295 | _squareV.userInteractionEnabled = NO; 296 | 297 | _squareV.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin; 298 | 299 | [self.view addSubview:_squareV]; 300 | } 301 | 302 | // -- LOAD ROTATION COVERS BEGIN -- // 303 | /* 304 | Rotating causes a weird flicker, I'm in the process of looking for a better 305 | solution, but for now, this works. 306 | */ 307 | 308 | // Stream Cover 309 | _rotationCover = [UIView new]; 310 | _rotationCover.backgroundColor = [UIColor blackColor]; 311 | _rotationCover.bounds = CGRectMake(0, 0, screenHeight * 3, screenHeight * 3); // 1 full screen size either direction 312 | _rotationCover.center = self.view.center; 313 | _rotationCover.autoresizingMask = UIViewAutoresizingNone; 314 | _rotationCover.alpha = 0; 315 | [self.view insertSubview:_rotationCover belowSubview:_imageStreamV]; 316 | // -- LOAD ROTATION COVERS END -- // 317 | 318 | // -- PREPARE OUR CONTROLS -- // 319 | [self loadControls]; 320 | 321 | // -- PREPARE CAMERA FLASH ANIMATION -- // 322 | 323 | if (_enableCameraCaptureAnimation) { 324 | if (cameraCaptureFlashAnimation) { 325 | [cameraCaptureFlashAnimation removeFromSuperview]; 326 | cameraCaptureFlashAnimation = nil; 327 | } 328 | 329 | cameraCaptureFlashAnimation = [[UIView alloc] initWithFrame:self.view.bounds]; 330 | cameraCaptureFlashAnimation.backgroundColor = [UIColor whiteColor]; 331 | cameraCaptureFlashAnimation.alpha = 0.0f; 332 | [self.view addSubview:cameraCaptureFlashAnimation]; 333 | } 334 | } 335 | 336 | #pragma mark CAMERA CONTROLS 337 | 338 | - (void) loadControls { 339 | 340 | // -- LOAD BUTTON IMAGES BEGIN -- // 341 | UIImage * previousImg = [UIImage imageNamed:@"Previous.png"]; 342 | UIImage * downloadImg = [UIImage imageNamed:@"Download.png"]; 343 | UIImage * lighteningImg = [UIImage imageNamed:@"Lightening.png"]; 344 | UIImage * cameraRotateImg = [UIImage imageNamed:@"CameraRotate.png"]; 345 | // -- LOAD BUTTON IMAGES END -- // 346 | 347 | // -- LOAD BUTTONS BEGIN -- // 348 | _backBtn = [UIButton buttonWithType:UIButtonTypeSystem]; 349 | [_backBtn addTarget:self action:@selector(backBtnPressed:) forControlEvents:UIControlEventTouchUpInside]; 350 | [_backBtn setImage:previousImg forState:UIControlStateNormal]; 351 | [_backBtn setTintColor:[self redColor]]; 352 | [_backBtn setImageEdgeInsets:UIEdgeInsetsMake(9, 10, 9, 13)]; 353 | 354 | _flashBtn = [UIButton buttonWithType:UIButtonTypeSystem]; 355 | [_flashBtn addTarget:self action:@selector(flashBtnPressed:) forControlEvents:UIControlEventTouchUpInside]; 356 | [_flashBtn setImage:lighteningImg forState:UIControlStateNormal]; 357 | [_flashBtn setTintColor:[self redColor]]; 358 | [_flashBtn setImageEdgeInsets:UIEdgeInsetsMake(6, 9, 6, 9)]; 359 | 360 | _switchCameraBtn = [UIButton buttonWithType:UIButtonTypeSystem]; 361 | [_switchCameraBtn setImage:cameraRotateImg forState:UIControlStateNormal]; 362 | [_switchCameraBtn setTintColor:[self blueColor]]; 363 | [_switchCameraBtn setImageEdgeInsets:UIEdgeInsetsMake(9.5, 7, 9.5, 7)]; 364 | 365 | _saveBtn = [UIButton buttonWithType:UIButtonTypeSystem]; 366 | [_saveBtn addTarget:self action:@selector(saveBtnPressed:) forControlEvents:UIControlEventTouchUpInside]; 367 | [_saveBtn setImage:downloadImg forState:UIControlStateNormal]; 368 | [_saveBtn setTintColor:[self blueColor]]; 369 | [_saveBtn setImageEdgeInsets:UIEdgeInsetsMake(7, 10.5, 7, 10.5)]; 370 | 371 | _captureBtn = [UIButton buttonWithType:UIButtonTypeSystem]; 372 | [_captureBtn addTarget:self action:@selector(captureBtnPressed:) forControlEvents:UIControlEventTouchUpInside]; 373 | [_captureBtn setTitle:NSLocalizedString(@"C\nA\nP\nT\nU\nR\nE", @"SimpleCam CAPTURE button for horizontal") forState:UIControlStateNormal]; 374 | [_captureBtn setTitleColor:[self darkGreyColor] forState:UIControlStateNormal]; 375 | _captureBtn.titleLabel.font = [UIFont systemFontOfSize:12.5]; 376 | _captureBtn.titleLabel.numberOfLines = 0; 377 | _captureBtn.titleLabel.minimumScaleFactor = .5; 378 | // -- LOAD BUTTONS END -- // 379 | 380 | // Stylize buttons 381 | for (UIButton * btn in @[_backBtn, _captureBtn, _flashBtn, _switchCameraBtn, _saveBtn]) { 382 | 383 | btn.bounds = CGRectMake(0, 0, 40, 40); 384 | btn.backgroundColor = [UIColor colorWithWhite:1 alpha:.96]; 385 | btn.alpha = optionAvailableAlpha; 386 | btn.hidden = YES; 387 | 388 | btn.layer.shouldRasterize = YES; 389 | btn.layer.rasterizationScale = [UIScreen mainScreen].scale; 390 | btn.layer.cornerRadius = 4; 391 | 392 | btn.layer.borderColor = [UIColor lightGrayColor].CGColor; 393 | btn.layer.borderWidth = 0.5; 394 | 395 | [self.view addSubview:btn]; 396 | } 397 | 398 | // If a device doesn't have multiple cameras, fade out button ... 399 | if ([AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo].count == 1) { 400 | _switchCameraBtn.alpha = optionUnavailableAlpha; 401 | } 402 | else { 403 | [_switchCameraBtn addTarget:self action:@selector(switchCameraBtnPressed:) forControlEvents:UIControlEventTouchUpInside]; 404 | } 405 | 406 | // Draw camera controls 407 | [self drawControls]; 408 | } 409 | 410 | - (void) drawControls { 411 | 412 | if (self.hideAllControls) { 413 | 414 | // In case they want to hide after they've been displayed 415 | // for (UIButton * btn in @[_backBtn, _captureBtn, _flashBtn, _switchCameraBtn, _saveBtn]) { 416 | // btn.hidden = YES; 417 | // } 418 | return; 419 | } 420 | 421 | static int offsetFromSide = 10; 422 | static int offsetBetweenButtons = 20; 423 | 424 | static CGFloat portraitFontSize = 16.0; 425 | static CGFloat landscapeFontSize = 12.5; 426 | 427 | [UIView animateWithDuration:self.controlAnimateDuration delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{ 428 | 429 | if (UIInterfaceOrientationIsPortrait(self.interfaceOrientation)) { 430 | 431 | CGFloat centerY = screenHeight - 8 - 20; // 8 is offset from bottom (portrait), 20 is half btn height 432 | 433 | _backBtn.center = CGPointMake(offsetFromSide + (_backBtn.bounds.size.width / 2), centerY); 434 | 435 | // offset from backbtn is '20' 436 | [_captureBtn setTitle:NSLocalizedString(@"CAPTURE", @"SimpleCam CAPTURE button") forState:UIControlStateNormal]; 437 | _captureBtn.titleLabel.font = [UIFont systemFontOfSize:portraitFontSize]; 438 | _captureBtn.bounds = CGRectMake(0, 0, 120, 40); 439 | _captureBtn.center = CGPointMake(_backBtn.center.x + (_backBtn.bounds.size.width / 2) + offsetBetweenButtons + (_captureBtn.bounds.size.width / 2), centerY); 440 | 441 | // offset from capturebtn is '20' 442 | _flashBtn.center = CGPointMake(_captureBtn.center.x + (_captureBtn.bounds.size.width / 2) + offsetBetweenButtons + (_flashBtn.bounds.size.width / 2), centerY); 443 | 444 | // offset from flashBtn is '20' 445 | _switchCameraBtn.center = CGPointMake(_flashBtn.center.x + (_flashBtn.bounds.size.width / 2) + offsetBetweenButtons + (_switchCameraBtn.bounds.size.width / 2), centerY); 446 | 447 | } 448 | else { 449 | CGFloat centerX = screenHeight - 8 - 20; // 8 is offset from side(landscape), 20 is half btn height 450 | 451 | // offset from side is '10' 452 | _backBtn.center = CGPointMake(centerX, offsetFromSide + (_backBtn.bounds.size.height / 2)); 453 | 454 | // offset from backbtn is '20' 455 | [_captureBtn setTitle:NSLocalizedString(@"C\nA\nP\nT\nU\nR\nE", @"SimpleCam CAPTURE button for horizontal") forState:UIControlStateNormal]; 456 | _captureBtn.titleLabel.font = [UIFont systemFontOfSize:landscapeFontSize]; 457 | _captureBtn.bounds = CGRectMake(0, 0, 40, 120); 458 | _captureBtn.center = CGPointMake(centerX, _backBtn.center.y + (_backBtn.bounds.size.height / 2) + offsetBetweenButtons + (_captureBtn.bounds.size.height / 2)); 459 | 460 | // offset from capturebtn is '20' 461 | _flashBtn.center = CGPointMake(centerX, _captureBtn.center.y + (_captureBtn.bounds.size.height / 2) + offsetBetweenButtons + (_flashBtn.bounds.size.height / 2)); 462 | 463 | // offset from flashBtn is '20' 464 | _switchCameraBtn.center = CGPointMake(centerX, _flashBtn.center.y + (_flashBtn.bounds.size.height / 2) + offsetBetweenButtons + (_switchCameraBtn.bounds.size.height / 2)); 465 | } 466 | 467 | // just so it's ready when we need it to be. 468 | _saveBtn.frame = _switchCameraBtn.frame; 469 | 470 | /* 471 | Show the proper controls for picture preview and picture stream 472 | */ 473 | 474 | // If camera preview -- show preview controls / hide capture controls 475 | if (_capturedImageV.image) { 476 | // Hide 477 | for (UIButton * btn in @[_captureBtn, _flashBtn, _switchCameraBtn]) btn.hidden = YES; 478 | // Show 479 | _saveBtn.hidden = NO; 480 | 481 | 482 | // Force User Preference 483 | _backBtn.hidden = _hideBackButton; 484 | } 485 | // ELSE camera stream -- show capture controls / hide preview controls 486 | else { 487 | // Show 488 | for (UIButton * btn in @[_flashBtn, _switchCameraBtn]) btn.hidden = NO; 489 | // Hide 490 | _saveBtn.hidden = YES; 491 | 492 | // Force User Preference 493 | _captureBtn.hidden = _hideCaptureButton; 494 | _backBtn.hidden = _hideBackButton; 495 | } 496 | 497 | [self evaluateFlashBtn]; 498 | 499 | } completion:nil]; 500 | } 501 | 502 | - (void) capturePhoto { 503 | if (isCapturingImage) { 504 | return; 505 | } 506 | isCapturingImage = YES; 507 | 508 | AVCaptureConnection *videoConnection = nil; 509 | for (AVCaptureConnection *connection in _stillImageOutput.connections) 510 | { 511 | for (AVCaptureInputPort *port in [connection inputPorts]) 512 | { 513 | if ([[port mediaType] isEqual:AVMediaTypeVideo] ) 514 | { 515 | videoConnection = connection; 516 | break; 517 | } 518 | } 519 | if (videoConnection) { break; } 520 | } 521 | 522 | [_stillImageOutput captureStillImageAsynchronouslyFromConnection:videoConnection completionHandler: ^(CMSampleBufferRef imageSampleBuffer, NSError *error) 523 | { 524 | // Camera "flash" animation 525 | if (_enableCameraCaptureAnimation) { 526 | [UIView animateWithDuration:0.2f animations:^{ 527 | cameraCaptureFlashAnimation.alpha = 1.0f;[cameraCaptureFlashAnimation setNeedsDisplay]; 528 | } completion:^(BOOL finished) { 529 | [UIView animateWithDuration:0.2f animations:^{ 530 | cameraCaptureFlashAnimation.alpha = 0.0f; 531 | }]; 532 | }]; 533 | } 534 | 535 | if(!CMSampleBufferIsValid(imageSampleBuffer)) 536 | { 537 | return; 538 | } 539 | NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageSampleBuffer]; 540 | 541 | UIImage * capturedImage = [[UIImage alloc]initWithData:imageData scale:1]; 542 | 543 | if (_myDevice == [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo][0]) { 544 | // rear camera active 545 | if (self.interfaceOrientation == UIInterfaceOrientationLandscapeRight) { 546 | CGImageRef cgRef = capturedImage.CGImage; 547 | capturedImage = [[UIImage alloc] initWithCGImage:cgRef scale:1.0 orientation:UIImageOrientationUp]; 548 | } 549 | else if (self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft) { 550 | CGImageRef cgRef = capturedImage.CGImage; 551 | capturedImage = [[UIImage alloc] initWithCGImage:cgRef scale:1.0 orientation:UIImageOrientationDown]; 552 | } 553 | } 554 | else if (_myDevice == [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo][1]) { 555 | // front camera active 556 | 557 | // flip to look the same as the camera 558 | if (UIInterfaceOrientationIsPortrait(self.interfaceOrientation)) 559 | capturedImage = [UIImage imageWithCGImage:capturedImage.CGImage scale:capturedImage.scale orientation:UIImageOrientationLeftMirrored]; 560 | else { 561 | if (self.interfaceOrientation == UIInterfaceOrientationLandscapeRight) 562 | capturedImage = [UIImage imageWithCGImage:capturedImage.CGImage scale:capturedImage.scale orientation:UIImageOrientationDownMirrored]; 563 | else if (self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft) 564 | capturedImage = [UIImage imageWithCGImage:capturedImage.CGImage scale:capturedImage.scale orientation:UIImageOrientationUpMirrored]; 565 | } 566 | 567 | } 568 | 569 | isCapturingImage = NO; 570 | _capturedImageV.image = [self crop:capturedImage]; 571 | // show captured image view 572 | _capturedImageV.alpha = 1.0f; 573 | // hide image stream view 574 | _imageStreamV.alpha = 0.0f; 575 | imageData = nil; 576 | 577 | // If we have disabled the photo preview directly fire the delegate callback, otherwise, show user a preview 578 | _disablePhotoPreview ? [self photoCaptured] : [self drawControls]; 579 | }]; 580 | } 581 | 582 | - (void) photoCaptured { 583 | if (isImageResized) { 584 | [_delegate simpleCam:self didFinishWithImage:_capturedImageV.image]; 585 | } 586 | else { 587 | isSaveWaitingForResizedImage = YES; 588 | [self resizeImage]; 589 | } 590 | } 591 | 592 | #pragma mark BUTTON EVENTS 593 | 594 | - (void) captureBtnPressed:(id)sender { 595 | [self capturePhoto]; 596 | } 597 | 598 | - (void) saveBtnPressed:(id)sender { 599 | [self photoCaptured]; 600 | } 601 | 602 | - (void) flashBtnPressed:(id)sender { 603 | if ([_myDevice isFlashAvailable]) { 604 | if (_myDevice.flashActive) { 605 | if([_myDevice lockForConfiguration:nil]) { 606 | _myDevice.flashMode = AVCaptureFlashModeOff; 607 | [_flashBtn setTintColor:[self redColor]]; 608 | } 609 | } 610 | else { 611 | if([_myDevice lockForConfiguration:nil]) { 612 | _myDevice.flashMode = AVCaptureFlashModeOn; 613 | [_flashBtn setTintColor:[self greenColor]]; 614 | } 615 | } 616 | [_myDevice unlockForConfiguration]; 617 | } 618 | } 619 | 620 | - (void) backBtnPressed:(id)sender { 621 | if (_capturedImageV.image) { 622 | _imageStreamV.alpha = 1.0f; 623 | _capturedImageV.contentMode = UIViewContentModeScaleAspectFill; 624 | _capturedImageV.backgroundColor = [UIColor clearColor]; 625 | _capturedImageV.image = nil; 626 | 627 | isRotateWaitingForResizedImage = NO; 628 | isImageResized = NO; 629 | isSaveWaitingForResizedImage = NO; 630 | 631 | [self.view insertSubview:_rotationCover belowSubview:_imageStreamV]; 632 | 633 | [self drawControls]; 634 | } 635 | else { 636 | [_delegate simpleCam:self didFinishWithImage:_capturedImageV.image]; 637 | } 638 | } 639 | 640 | - (void) switchCameraBtnPressed:(id)sender { 641 | if (isCapturingImage != YES) { 642 | if (_myDevice == [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo][0]) { 643 | // rear active, switch to front 644 | _myDevice = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo][1]; 645 | 646 | [_mySesh beginConfiguration]; 647 | AVCaptureDeviceInput * newInput = [AVCaptureDeviceInput deviceInputWithDevice:_myDevice error:nil]; 648 | for (AVCaptureInput * oldInput in _mySesh.inputs) { 649 | [_mySesh removeInput:oldInput]; 650 | } 651 | [_mySesh addInput:newInput]; 652 | [_mySesh commitConfiguration]; 653 | } 654 | else if (_myDevice == [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo][1]) { 655 | // front active, switch to rear 656 | _myDevice = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo][0]; 657 | [_mySesh beginConfiguration]; 658 | AVCaptureDeviceInput * newInput = [AVCaptureDeviceInput deviceInputWithDevice:_myDevice error:nil]; 659 | for (AVCaptureInput * oldInput in _mySesh.inputs) { 660 | [_mySesh removeInput:oldInput]; 661 | } 662 | [_mySesh addInput:newInput]; 663 | [_mySesh commitConfiguration]; 664 | } 665 | 666 | // Need to reset flash btn 667 | [self evaluateFlashBtn]; 668 | } 669 | } 670 | 671 | - (void) evaluateFlashBtn { 672 | // Evaluate Flash Available? 673 | if (_myDevice.isFlashAvailable) { 674 | _flashBtn.alpha = optionAvailableAlpha; 675 | 676 | // Evaluate Flash Active? 677 | if (_myDevice.isFlashActive) { 678 | [_flashBtn setTintColor:[self greenColor]]; 679 | } 680 | else { 681 | [_flashBtn setTintColor:[self redColor]]; 682 | } 683 | } 684 | else { 685 | _flashBtn.alpha = optionUnavailableAlpha; 686 | [_flashBtn setTintColor:[self darkGreyColor]]; 687 | } 688 | } 689 | 690 | #pragma mark TAP TO FOCUS 691 | 692 | - (void) tapSent:(UITapGestureRecognizer *)sender { 693 | 694 | if (_capturedImageV.image == nil) { 695 | CGPoint aPoint = [sender locationInView:_imageStreamV]; 696 | if (_myDevice != nil) { 697 | if([_myDevice isFocusPointOfInterestSupported] && 698 | [_myDevice isFocusModeSupported:AVCaptureFocusModeAutoFocus]) { 699 | 700 | // we subtract the point from the width to inverse the focal point 701 | // focus points of interest represents a CGPoint where 702 | // {0,0} corresponds to the top left of the picture area, and 703 | // {1,1} corresponds to the bottom right in landscape mode with the home button on the right— 704 | // THIS APPLIES EVEN IF THE DEVICE IS IN PORTRAIT MODE 705 | // (from docs) 706 | // this is all a touch wonky 707 | double pX = aPoint.x / _imageStreamV.bounds.size.width; 708 | double pY = aPoint.y / _imageStreamV.bounds.size.height; 709 | double focusX = pY; 710 | // x is equal to y but y is equal to inverse x ? 711 | double focusY = 1 - pX; 712 | 713 | //NSLog(@"SC: about to focus at x: %f, y: %f", focusX, focusY); 714 | if([_myDevice isFocusPointOfInterestSupported] && [_myDevice isFocusModeSupported:AVCaptureFocusModeAutoFocus]) { 715 | 716 | if([_myDevice lockForConfiguration:nil]) { 717 | [_myDevice setFocusPointOfInterest:CGPointMake(focusX, focusY)]; 718 | [_myDevice setFocusMode:AVCaptureFocusModeAutoFocus]; 719 | [_myDevice setExposurePointOfInterest:CGPointMake(focusX, focusY)]; 720 | [_myDevice setExposureMode:AVCaptureExposureModeContinuousAutoExposure]; 721 | //NSLog(@"SC: Done Focusing"); 722 | } 723 | [_myDevice unlockForConfiguration]; 724 | } 725 | } 726 | } 727 | } 728 | } 729 | 730 | #pragma mark PINCH TO ZOOM 731 | 732 | - (void) pinchToZoom:(UIPinchGestureRecognizer *)gestureRecognizer { 733 | 734 | if([gestureRecognizer state] == UIGestureRecognizerStateBegan) { 735 | // Reset the last scale, necessary if there are multiple objects with different scales 736 | scale = [gestureRecognizer scale]; 737 | } 738 | 739 | if ([gestureRecognizer state] == UIGestureRecognizerStateBegan || 740 | [gestureRecognizer state] == UIGestureRecognizerStateChanged) { 741 | 742 | CGFloat currentScale = [[_imageStreamV.layer valueForKeyPath:@"transform.scale"] floatValue]; 743 | 744 | // Constants to adjust the max/min values of zoom 745 | const CGFloat kMaxScale = 2.0; 746 | const CGFloat kMinScale = 1.0; 747 | 748 | CGFloat newScale = 1 - (scale - [gestureRecognizer scale]); 749 | newScale = MIN(newScale, kMaxScale / currentScale); 750 | newScale = MAX(newScale, kMinScale / currentScale); 751 | 752 | CGAffineTransform transform = CGAffineTransformScale([_imageStreamV transform], newScale, newScale); 753 | _imageStreamV.transform = transform; 754 | 755 | scale = [gestureRecognizer scale]; // Store the previous scale factor for the next pinch gesture call 756 | } 757 | } 758 | 759 | #pragma mark RESIZE IMAGE 760 | 761 | - (void) resizeImage { 762 | 763 | // Set Orientation 764 | BOOL isLandscape = UIInterfaceOrientationIsLandscape(self.interfaceOrientation) ? YES : NO; 765 | 766 | // Set Size 767 | CGSize size = (isLandscape) ? CGSizeMake(screenHeight, screenWidth) : CGSizeMake(screenWidth, screenHeight); 768 | if (_isSquareMode) size = _squareV.bounds.size; 769 | 770 | // Set Draw Rect 771 | CGRect drawRect = (isLandscape) ? ({ 772 | // IS CURRENTLY LANDSCAPE 773 | 774 | // targetHeight is the height our image would need to be at the current screenwidth if we maintained the image ratio. 775 | CGFloat targetHeight = screenHeight * 0.75; // 3:4 ratio 776 | 777 | // we have to draw around the context of the screen 778 | // our final image will be the image that is left in the frame of the context 779 | // by drawing outside it, we remove the edges of the picture 780 | CGFloat offsetTop = (targetHeight - size.height) / 2; 781 | CGFloat offsetLeft = (screenHeight - size.width) / 2; 782 | CGRectMake(-offsetLeft, -offsetTop, screenHeight, targetHeight); 783 | }) : ({ 784 | // IS CURRENTLY PORTRAIT 785 | 786 | // targetWidth is the width our image would need to be at the current screenheight if we maintained the image ratio. 787 | CGFloat targetWidth = screenHeight * 0.75; // 3:4 ratio 788 | 789 | // we have to draw around the context of the screen 790 | // our final image will be the image that is left in the frame of the context 791 | // by drawing outside it, we remove the edges of the picture 792 | CGFloat offsetTop = (screenHeight - size.height) / 2; 793 | CGFloat offsetLeft = (targetWidth - size.width) / 2; 794 | CGRectMake(-offsetLeft, -offsetTop, targetWidth, screenHeight); 795 | }); 796 | 797 | // START CONTEXT 798 | UIGraphicsBeginImageContextWithOptions(size, YES, 2.0); 799 | [_capturedImageV.image drawInRect:drawRect]; 800 | _capturedImageV.image = UIGraphicsGetImageFromCurrentImageContext(); 801 | UIGraphicsEndImageContext(); 802 | // END CONTEXT 803 | 804 | 805 | // See if someone's waiting for resized image 806 | if (isSaveWaitingForResizedImage == YES) [_delegate simpleCam:self didFinishWithImage:_capturedImageV.image]; 807 | if (isRotateWaitingForResizedImage == YES) _capturedImageV.contentMode = UIViewContentModeScaleAspectFit; 808 | 809 | isImageResized = YES; 810 | } 811 | 812 | - (UIImage *)crop:(UIImage *)img { 813 | CGFloat currentScale = [[_imageStreamV.layer valueForKeyPath:@"transform.scale"] floatValue]; 814 | 815 | NSInteger newW = img.size.width / currentScale; 816 | NSInteger newH = img.size.height / currentScale; 817 | NSInteger newX1 = (img.size.width / 2) - (newW / 2); 818 | NSInteger newY1 = (img.size.height / 2) - (newH / 2); 819 | 820 | CGRect rect = { -newX1, -newY1, img.size.width, img.size.height }; 821 | 822 | UIGraphicsBeginImageContextWithOptions(CGSizeMake(newW, newH), true, 1.0); 823 | 824 | [img drawInRect:rect]; 825 | UIImage *result = UIGraphicsGetImageFromCurrentImageContext(); 826 | UIGraphicsEndImageContext(); 827 | 828 | return result; 829 | } 830 | 831 | #pragma mark ROTATION 832 | 833 | - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { 834 | 835 | if (_capturedImageV.image) { 836 | _capturedImageV.backgroundColor = [UIColor blackColor]; 837 | 838 | // Move for rotation 839 | [self.view insertSubview:_rotationCover belowSubview:_capturedImageV]; 840 | 841 | if (!isImageResized) { 842 | isRotateWaitingForResizedImage = YES; 843 | [self resizeImage]; 844 | } 845 | } 846 | 847 | CGRect targetRect; 848 | if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) { 849 | targetRect = CGRectMake(0, 0, screenHeight, screenWidth); 850 | 851 | if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) { 852 | _captureVideoPreviewLayer.connection.videoOrientation = AVCaptureVideoOrientationLandscapeLeft; 853 | } 854 | else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) { 855 | _captureVideoPreviewLayer.connection.videoOrientation = AVCaptureVideoOrientationLandscapeRight; 856 | } 857 | 858 | } 859 | else { 860 | targetRect = CGRectMake(0, 0, screenWidth, screenHeight); 861 | _captureVideoPreviewLayer.connection.videoOrientation = AVCaptureVideoOrientationPortrait; 862 | } 863 | 864 | // reset zoom 865 | _imageStreamV.transform = CGAffineTransformIdentity; 866 | 867 | [UIView animateWithDuration:duration delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{ 868 | for (UIView * v in @[_capturedImageV, _imageStreamV, self.view]) { 869 | v.frame = targetRect; 870 | } 871 | 872 | // not in for statement, cuz layer 873 | _captureVideoPreviewLayer.frame = _imageStreamV.bounds; 874 | 875 | } completion:^(BOOL finished) { 876 | [self drawControls]; 877 | }]; 878 | 879 | } 880 | 881 | #pragma mark CLOSE 882 | 883 | - (void) closeWithCompletion:(void (^)(void))completion { 884 | 885 | // Need alpha 0.0 before dismissing otherwise sticks out on dismissal 886 | _rotationCover.alpha = 0.0; 887 | 888 | [self dismissViewControllerAnimated:YES completion:^{ 889 | 890 | completion(); 891 | 892 | // Clean Up 893 | isImageResized = NO; 894 | isSaveWaitingForResizedImage = NO; 895 | isRotateWaitingForResizedImage = NO; 896 | 897 | [_mySesh stopRunning]; 898 | _mySesh = nil; 899 | 900 | _capturedImageV.image = nil; 901 | [_capturedImageV removeFromSuperview]; 902 | _capturedImageV = nil; 903 | 904 | [_imageStreamV removeFromSuperview]; 905 | _imageStreamV = nil; 906 | 907 | [_rotationCover removeFromSuperview]; 908 | _rotationCover = nil; 909 | 910 | _stillImageOutput = nil; 911 | _myDevice = nil; 912 | 913 | self.view = nil; 914 | _delegate = nil; 915 | [self removeFromParentViewController]; 916 | 917 | }]; 918 | } 919 | 920 | #pragma mark COLORS 921 | 922 | - (UIColor *) darkGreyColor { 923 | return [UIColor colorWithRed:0.226082 green:0.244034 blue:0.297891 alpha:1]; 924 | } 925 | - (UIColor *) redColor { 926 | return [UIColor colorWithRed:1 green:0 blue:0.105670 alpha:.6]; 927 | } 928 | - (UIColor *) greenColor { 929 | return [UIColor colorWithRed:0.128085 green:.749103 blue:0.004684 alpha:0.6]; 930 | } 931 | - (UIColor *) blueColor { 932 | return [UIColor colorWithRed:0 green:.478431 blue:1 alpha:1]; 933 | } 934 | 935 | #pragma mark STATUS BAR 936 | 937 | - (BOOL)prefersStatusBarHidden { 938 | return YES; 939 | } 940 | 941 | #pragma mark GETTERS | SETTERS 942 | 943 | - (void) setHideAllControls:(BOOL)hideAllControls { 944 | _hideAllControls = hideAllControls; 945 | 946 | // This way, hideAllControls can be used as a toggle. 947 | [self drawControls]; 948 | } 949 | - (BOOL) hideAllControls { 950 | return _hideAllControls; 951 | } 952 | - (void) setHideBackButton:(BOOL)hideBackButton { 953 | _hideBackButton = hideBackButton; 954 | _backBtn.hidden = _hideBackButton; 955 | } 956 | - (BOOL) hideBackButton { 957 | return _hideBackButton; 958 | } 959 | - (void) setHideCaptureButton:(BOOL)hideCaptureButton { 960 | _hideCaptureButton = hideCaptureButton; 961 | _captureBtn.hidden = YES; 962 | } 963 | - (BOOL) hideCaptureButton { 964 | return _hideCaptureButton; 965 | } 966 | 967 | @end 968 | -------------------------------------------------------------------------------- /SimpleCam/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /SimpleCam/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // SimpleCam 4 | // 5 | // Created by Logan Wright on 3/31/14. 6 | // Copyright (c) 2014 Logan Wright. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "AppDelegate.h" 12 | 13 | int main(int argc, char * argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /SimpleCamTests/SimpleCamTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | lowri.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /SimpleCamTests/SimpleCamTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // SimpleCamTests.m 3 | // SimpleCamTests 4 | // 5 | // Created by Logan Wright on 3/31/14. 6 | // Copyright (c) 2014 Logan Wright. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SimpleCamTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation SimpleCamTests 16 | 17 | - (void)setUp 18 | { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown 24 | { 25 | // Put teardown code here. This method is called after the invocation of each test method in the class. 26 | [super tearDown]; 27 | } 28 | 29 | - (void)testExample 30 | { 31 | XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__); 32 | } 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /SimpleCamTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | --------------------------------------------------------------------------------