├── .gitignore ├── AvatarCapture.podspec ├── AvatarCapture ├── AvatarCapture.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── AvatarCapture.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist ├── AvatarCapture │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── Capture │ │ │ ├── Contents.json │ │ │ ├── close.imageset │ │ │ │ ├── Contents.json │ │ │ │ ├── close.png │ │ │ │ ├── close@2x.png │ │ │ │ └── close@3x.png │ │ │ ├── flash.imageset │ │ │ │ ├── Contents.json │ │ │ │ ├── flash.png │ │ │ │ └── flash@2x.png │ │ │ ├── flashselected.imageset │ │ │ │ ├── Contents.json │ │ │ │ ├── flashselected.png │ │ │ │ └── flashselected@2x.png │ │ │ ├── front-camera.imageset │ │ │ │ ├── Contents.json │ │ │ │ ├── front-camera.png │ │ │ │ └── front-camera@2x.png │ │ │ ├── library.imageset │ │ │ │ ├── Contents.json │ │ │ │ ├── library.png │ │ │ │ └── library@2x.png │ │ │ ├── selected.imageset │ │ │ │ ├── Contents.json │ │ │ │ ├── selected.png │ │ │ │ └── selected@2x.png │ │ │ └── shutter.imageset │ │ │ │ ├── Contents.json │ │ │ │ ├── shutter.png │ │ │ │ ├── shutter@2x.png │ │ │ │ └── shutter@3x.png │ │ └── Contents.json │ ├── AvatarCaptureController.swift │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Example │ │ ├── MainViewController.swift │ │ └── chin.png │ ├── Info.plist │ ├── MainViewViewController.swift │ ├── New Group │ │ └── chin.png │ └── capture_me.gif └── Podfile ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | .DS_Store 25 | 26 | ## Obj-C/Swift specific 27 | *.hmap 28 | *.ipa 29 | *.dSYM.zip 30 | *.dSYM 31 | 32 | ## Playgrounds 33 | timeline.xctimeline 34 | playground.xcworkspace 35 | 36 | # Swift Package Manager 37 | # 38 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 39 | # Packages/ 40 | # Package.pins 41 | .build/ 42 | 43 | # CocoaPods 44 | # 45 | # We recommend against adding the Pods directory to your .gitignore. However 46 | # you should judge for yourself, the pros and cons are mentioned at: 47 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 48 | # 49 | # Pods/ 50 | 51 | # Carthage 52 | # 53 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 54 | # Carthage/Checkouts 55 | 56 | Carthage/Build 57 | 58 | # fastlane 59 | # 60 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 61 | # screenshots whenever they are needed. 62 | # For more information about the recommended setup visit: 63 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 64 | 65 | fastlane/report.xml 66 | fastlane/Preview.html 67 | fastlane/screenshots 68 | fastlane/test_output 69 | -------------------------------------------------------------------------------- /AvatarCapture.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'AvatarCapture' 3 | s.version = '1.1.0' 4 | s.summary = 'A Swift based drop in solution for taking avatar/profile pictures using the iOS Camera' 5 | 6 | s.description = <<-DESC 7 | Writing a ground-up solution for taking profile pictures in iOS can be a pain and time consuming. AvatarCapture is a Swift based library whose purpose is to make it easy as possible to start your camera, allow you to snap a photo or choose a photo from your Photos library. 8 | DESC 9 | 10 | s.homepage = 'https://github.com/gatewayapps/avatar-capture-ios' 11 | s.license = { :type => 'MIT', :file => 'LICENSE' } 12 | s.author = { 'John Murphy' => 'john@gatewayapps.com' } 13 | s.social_media_url = "https://twitter.com/johnmurphy01" 14 | s.source = { :git => 'https://github.com/gatewayapps/avatar-capture-ios.git', :tag => s.version.to_s } 15 | 16 | s.ios.deployment_target = '10.0' 17 | s.swift_version = '4.0' 18 | s.resource_bundles = { 19 | 'AvatarCapture' => ['AvatarCapture/*/Assets.xcassets'] 20 | } 21 | s.dependency 'FontAwesome.swift', '~> 1.3.0' 22 | s.source_files = 'AvatarCapture/AvatarCapture/AvatarCaptureController.swift' 23 | 24 | end 25 | -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 821BE7D42075766E001A7D7C /* MainViewViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 821BE7D32075766E001A7D7C /* MainViewViewController.swift */; }; 11 | 82680F39206C91C000A1277F /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82680F38206C91C000A1277F /* AppDelegate.swift */; }; 12 | 82680F3E206C91C000A1277F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 82680F3C206C91C000A1277F /* Main.storyboard */; }; 13 | 82680F40206C91C000A1277F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 82680F3F206C91C000A1277F /* Assets.xcassets */; }; 14 | 82680F43206C91C000A1277F /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 82680F41206C91C000A1277F /* LaunchScreen.storyboard */; }; 15 | 82680F4B206C926900A1277F /* AvatarCaptureController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82680F4A206C926900A1277F /* AvatarCaptureController.swift */; }; 16 | 8296C6FD207570BD00FEBEDB /* chin.png in Resources */ = {isa = PBXBuildFile; fileRef = 8296C6FB207570BD00FEBEDB /* chin.png */; }; 17 | E7078100C2107BE62B112237 /* Pods_AvatarCapture.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B8C323117F2E7B629E48CDA4 /* Pods_AvatarCapture.framework */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXFileReference section */ 21 | 26110AF74EF70126A1BCCADB /* Pods-AvatarCapture.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AvatarCapture.debug.xcconfig"; path = "Pods/Target Support Files/Pods-AvatarCapture/Pods-AvatarCapture.debug.xcconfig"; sourceTree = ""; }; 22 | 7C6D0ECC02A771FE47E81BD3 /* Pods-AvatarCapture.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AvatarCapture.release.xcconfig"; path = "Pods/Target Support Files/Pods-AvatarCapture/Pods-AvatarCapture.release.xcconfig"; sourceTree = ""; }; 23 | 821BE7D32075766E001A7D7C /* MainViewViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainViewViewController.swift; sourceTree = ""; }; 24 | 82680F35206C91C000A1277F /* AvatarCapture.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AvatarCapture.app; sourceTree = BUILT_PRODUCTS_DIR; }; 25 | 82680F38206C91C000A1277F /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 26 | 82680F3D206C91C000A1277F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 27 | 82680F3F206C91C000A1277F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 28 | 82680F42206C91C000A1277F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 29 | 82680F44206C91C000A1277F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 30 | 82680F4A206C926900A1277F /* AvatarCaptureController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AvatarCaptureController.swift; sourceTree = ""; }; 31 | 8296C6FB207570BD00FEBEDB /* chin.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = chin.png; sourceTree = ""; }; 32 | B8C323117F2E7B629E48CDA4 /* Pods_AvatarCapture.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_AvatarCapture.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 33 | /* End PBXFileReference section */ 34 | 35 | /* Begin PBXFrameworksBuildPhase section */ 36 | 82680F32206C91C000A1277F /* Frameworks */ = { 37 | isa = PBXFrameworksBuildPhase; 38 | buildActionMask = 2147483647; 39 | files = ( 40 | E7078100C2107BE62B112237 /* Pods_AvatarCapture.framework in Frameworks */, 41 | ); 42 | runOnlyForDeploymentPostprocessing = 0; 43 | }; 44 | /* End PBXFrameworksBuildPhase section */ 45 | 46 | /* Begin PBXGroup section */ 47 | 82680F2C206C91C000A1277F = { 48 | isa = PBXGroup; 49 | children = ( 50 | 82680F37206C91C000A1277F /* AvatarCapture */, 51 | 82680F36206C91C000A1277F /* Products */, 52 | 86F8BCAFE0FFE6ACB90A52DA /* Pods */, 53 | C8E0329552C74A77E1092393 /* Frameworks */, 54 | ); 55 | sourceTree = ""; 56 | }; 57 | 82680F36206C91C000A1277F /* Products */ = { 58 | isa = PBXGroup; 59 | children = ( 60 | 82680F35206C91C000A1277F /* AvatarCapture.app */, 61 | ); 62 | name = Products; 63 | sourceTree = ""; 64 | }; 65 | 82680F37206C91C000A1277F /* AvatarCapture */ = { 66 | isa = PBXGroup; 67 | children = ( 68 | 8296C6FA207570AE00FEBEDB /* Example */, 69 | 82680F4A206C926900A1277F /* AvatarCaptureController.swift */, 70 | 82680F38206C91C000A1277F /* AppDelegate.swift */, 71 | 82680F3C206C91C000A1277F /* Main.storyboard */, 72 | 82680F3F206C91C000A1277F /* Assets.xcassets */, 73 | 82680F41206C91C000A1277F /* LaunchScreen.storyboard */, 74 | 82680F44206C91C000A1277F /* Info.plist */, 75 | 821BE7D32075766E001A7D7C /* MainViewViewController.swift */, 76 | ); 77 | path = AvatarCapture; 78 | sourceTree = ""; 79 | }; 80 | 8296C6FA207570AE00FEBEDB /* Example */ = { 81 | isa = PBXGroup; 82 | children = ( 83 | 8296C6FB207570BD00FEBEDB /* chin.png */, 84 | ); 85 | name = Example; 86 | path = "New Group"; 87 | sourceTree = ""; 88 | }; 89 | 86F8BCAFE0FFE6ACB90A52DA /* Pods */ = { 90 | isa = PBXGroup; 91 | children = ( 92 | 26110AF74EF70126A1BCCADB /* Pods-AvatarCapture.debug.xcconfig */, 93 | 7C6D0ECC02A771FE47E81BD3 /* Pods-AvatarCapture.release.xcconfig */, 94 | ); 95 | name = Pods; 96 | sourceTree = ""; 97 | }; 98 | C8E0329552C74A77E1092393 /* Frameworks */ = { 99 | isa = PBXGroup; 100 | children = ( 101 | B8C323117F2E7B629E48CDA4 /* Pods_AvatarCapture.framework */, 102 | ); 103 | name = Frameworks; 104 | sourceTree = ""; 105 | }; 106 | /* End PBXGroup section */ 107 | 108 | /* Begin PBXNativeTarget section */ 109 | 82680F34206C91C000A1277F /* AvatarCapture */ = { 110 | isa = PBXNativeTarget; 111 | buildConfigurationList = 82680F47206C91C000A1277F /* Build configuration list for PBXNativeTarget "AvatarCapture" */; 112 | buildPhases = ( 113 | 5D8528E783586968397D5963 /* [CP] Check Pods Manifest.lock */, 114 | 82680F31206C91C000A1277F /* Sources */, 115 | 82680F32206C91C000A1277F /* Frameworks */, 116 | 82680F33206C91C000A1277F /* Resources */, 117 | C38F4A179CE837B15CB31BA7 /* [CP] Embed Pods Frameworks */, 118 | 33A8AF73F3E6DB3906CDDB5C /* [CP] Copy Pods Resources */, 119 | ); 120 | buildRules = ( 121 | ); 122 | dependencies = ( 123 | ); 124 | name = AvatarCapture; 125 | productName = AvatarCapture; 126 | productReference = 82680F35206C91C000A1277F /* AvatarCapture.app */; 127 | productType = "com.apple.product-type.application"; 128 | }; 129 | /* End PBXNativeTarget section */ 130 | 131 | /* Begin PBXProject section */ 132 | 82680F2D206C91C000A1277F /* Project object */ = { 133 | isa = PBXProject; 134 | attributes = { 135 | LastSwiftUpdateCheck = 0920; 136 | LastUpgradeCheck = 0930; 137 | ORGANIZATIONNAME = "John Murphy"; 138 | TargetAttributes = { 139 | 82680F34206C91C000A1277F = { 140 | CreatedOnToolsVersion = 9.2; 141 | ProvisioningStyle = Automatic; 142 | }; 143 | }; 144 | }; 145 | buildConfigurationList = 82680F30206C91C000A1277F /* Build configuration list for PBXProject "AvatarCapture" */; 146 | compatibilityVersion = "Xcode 8.0"; 147 | developmentRegion = en; 148 | hasScannedForEncodings = 0; 149 | knownRegions = ( 150 | en, 151 | Base, 152 | ); 153 | mainGroup = 82680F2C206C91C000A1277F; 154 | productRefGroup = 82680F36206C91C000A1277F /* Products */; 155 | projectDirPath = ""; 156 | projectRoot = ""; 157 | targets = ( 158 | 82680F34206C91C000A1277F /* AvatarCapture */, 159 | ); 160 | }; 161 | /* End PBXProject section */ 162 | 163 | /* Begin PBXResourcesBuildPhase section */ 164 | 82680F33206C91C000A1277F /* Resources */ = { 165 | isa = PBXResourcesBuildPhase; 166 | buildActionMask = 2147483647; 167 | files = ( 168 | 82680F43206C91C000A1277F /* LaunchScreen.storyboard in Resources */, 169 | 8296C6FD207570BD00FEBEDB /* chin.png in Resources */, 170 | 82680F40206C91C000A1277F /* Assets.xcassets in Resources */, 171 | 82680F3E206C91C000A1277F /* Main.storyboard in Resources */, 172 | ); 173 | runOnlyForDeploymentPostprocessing = 0; 174 | }; 175 | /* End PBXResourcesBuildPhase section */ 176 | 177 | /* Begin PBXShellScriptBuildPhase section */ 178 | 33A8AF73F3E6DB3906CDDB5C /* [CP] Copy Pods Resources */ = { 179 | isa = PBXShellScriptBuildPhase; 180 | buildActionMask = 2147483647; 181 | files = ( 182 | ); 183 | inputPaths = ( 184 | ); 185 | name = "[CP] Copy Pods Resources"; 186 | outputPaths = ( 187 | ); 188 | runOnlyForDeploymentPostprocessing = 0; 189 | shellPath = /bin/sh; 190 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AvatarCapture/Pods-AvatarCapture-resources.sh\"\n"; 191 | showEnvVarsInLog = 0; 192 | }; 193 | 5D8528E783586968397D5963 /* [CP] Check Pods Manifest.lock */ = { 194 | isa = PBXShellScriptBuildPhase; 195 | buildActionMask = 2147483647; 196 | files = ( 197 | ); 198 | inputPaths = ( 199 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 200 | "${PODS_ROOT}/Manifest.lock", 201 | ); 202 | name = "[CP] Check Pods Manifest.lock"; 203 | outputPaths = ( 204 | "$(DERIVED_FILE_DIR)/Pods-AvatarCapture-checkManifestLockResult.txt", 205 | ); 206 | runOnlyForDeploymentPostprocessing = 0; 207 | shellPath = /bin/sh; 208 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 209 | showEnvVarsInLog = 0; 210 | }; 211 | C38F4A179CE837B15CB31BA7 /* [CP] Embed Pods Frameworks */ = { 212 | isa = PBXShellScriptBuildPhase; 213 | buildActionMask = 2147483647; 214 | files = ( 215 | ); 216 | inputPaths = ( 217 | "${SRCROOT}/Pods/Target Support Files/Pods-AvatarCapture/Pods-AvatarCapture-frameworks.sh", 218 | "${BUILT_PRODUCTS_DIR}/FontAwesome.swift/FontAwesome_swift.framework", 219 | ); 220 | name = "[CP] Embed Pods Frameworks"; 221 | outputPaths = ( 222 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FontAwesome_swift.framework", 223 | ); 224 | runOnlyForDeploymentPostprocessing = 0; 225 | shellPath = /bin/sh; 226 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AvatarCapture/Pods-AvatarCapture-frameworks.sh\"\n"; 227 | showEnvVarsInLog = 0; 228 | }; 229 | /* End PBXShellScriptBuildPhase section */ 230 | 231 | /* Begin PBXSourcesBuildPhase section */ 232 | 82680F31206C91C000A1277F /* Sources */ = { 233 | isa = PBXSourcesBuildPhase; 234 | buildActionMask = 2147483647; 235 | files = ( 236 | 82680F39206C91C000A1277F /* AppDelegate.swift in Sources */, 237 | 821BE7D42075766E001A7D7C /* MainViewViewController.swift in Sources */, 238 | 82680F4B206C926900A1277F /* AvatarCaptureController.swift in Sources */, 239 | ); 240 | runOnlyForDeploymentPostprocessing = 0; 241 | }; 242 | /* End PBXSourcesBuildPhase section */ 243 | 244 | /* Begin PBXVariantGroup section */ 245 | 82680F3C206C91C000A1277F /* Main.storyboard */ = { 246 | isa = PBXVariantGroup; 247 | children = ( 248 | 82680F3D206C91C000A1277F /* Base */, 249 | ); 250 | name = Main.storyboard; 251 | sourceTree = ""; 252 | }; 253 | 82680F41206C91C000A1277F /* LaunchScreen.storyboard */ = { 254 | isa = PBXVariantGroup; 255 | children = ( 256 | 82680F42206C91C000A1277F /* Base */, 257 | ); 258 | name = LaunchScreen.storyboard; 259 | sourceTree = ""; 260 | }; 261 | /* End PBXVariantGroup section */ 262 | 263 | /* Begin XCBuildConfiguration section */ 264 | 82680F45206C91C000A1277F /* Debug */ = { 265 | isa = XCBuildConfiguration; 266 | buildSettings = { 267 | ALWAYS_SEARCH_USER_PATHS = NO; 268 | CLANG_ANALYZER_NONNULL = YES; 269 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 270 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 271 | CLANG_CXX_LIBRARY = "libc++"; 272 | CLANG_ENABLE_MODULES = YES; 273 | CLANG_ENABLE_OBJC_ARC = YES; 274 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 275 | CLANG_WARN_BOOL_CONVERSION = YES; 276 | CLANG_WARN_COMMA = YES; 277 | CLANG_WARN_CONSTANT_CONVERSION = YES; 278 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 279 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 280 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 281 | CLANG_WARN_EMPTY_BODY = YES; 282 | CLANG_WARN_ENUM_CONVERSION = YES; 283 | CLANG_WARN_INFINITE_RECURSION = YES; 284 | CLANG_WARN_INT_CONVERSION = YES; 285 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 286 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 287 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 288 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 289 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 290 | CLANG_WARN_STRICT_PROTOTYPES = YES; 291 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 292 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 293 | CLANG_WARN_UNREACHABLE_CODE = YES; 294 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 295 | CODE_SIGN_IDENTITY = "iPhone Developer"; 296 | COPY_PHASE_STRIP = NO; 297 | DEBUG_INFORMATION_FORMAT = dwarf; 298 | ENABLE_STRICT_OBJC_MSGSEND = YES; 299 | ENABLE_TESTABILITY = YES; 300 | GCC_C_LANGUAGE_STANDARD = gnu11; 301 | GCC_DYNAMIC_NO_PIC = NO; 302 | GCC_NO_COMMON_BLOCKS = YES; 303 | GCC_OPTIMIZATION_LEVEL = 0; 304 | GCC_PREPROCESSOR_DEFINITIONS = ( 305 | "DEBUG=1", 306 | "$(inherited)", 307 | ); 308 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 309 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 310 | GCC_WARN_UNDECLARED_SELECTOR = YES; 311 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 312 | GCC_WARN_UNUSED_FUNCTION = YES; 313 | GCC_WARN_UNUSED_VARIABLE = YES; 314 | IPHONEOS_DEPLOYMENT_TARGET = 11.2; 315 | MTL_ENABLE_DEBUG_INFO = YES; 316 | ONLY_ACTIVE_ARCH = YES; 317 | SDKROOT = iphoneos; 318 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 319 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 320 | }; 321 | name = Debug; 322 | }; 323 | 82680F46206C91C000A1277F /* Release */ = { 324 | isa = XCBuildConfiguration; 325 | buildSettings = { 326 | ALWAYS_SEARCH_USER_PATHS = NO; 327 | CLANG_ANALYZER_NONNULL = YES; 328 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 329 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 330 | CLANG_CXX_LIBRARY = "libc++"; 331 | CLANG_ENABLE_MODULES = YES; 332 | CLANG_ENABLE_OBJC_ARC = YES; 333 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 334 | CLANG_WARN_BOOL_CONVERSION = YES; 335 | CLANG_WARN_COMMA = YES; 336 | CLANG_WARN_CONSTANT_CONVERSION = YES; 337 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 338 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 339 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 340 | CLANG_WARN_EMPTY_BODY = YES; 341 | CLANG_WARN_ENUM_CONVERSION = YES; 342 | CLANG_WARN_INFINITE_RECURSION = YES; 343 | CLANG_WARN_INT_CONVERSION = YES; 344 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 345 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 346 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 347 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 348 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 349 | CLANG_WARN_STRICT_PROTOTYPES = YES; 350 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 351 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 352 | CLANG_WARN_UNREACHABLE_CODE = YES; 353 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 354 | CODE_SIGN_IDENTITY = "iPhone Developer"; 355 | COPY_PHASE_STRIP = NO; 356 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 357 | ENABLE_NS_ASSERTIONS = NO; 358 | ENABLE_STRICT_OBJC_MSGSEND = YES; 359 | GCC_C_LANGUAGE_STANDARD = gnu11; 360 | GCC_NO_COMMON_BLOCKS = YES; 361 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 362 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 363 | GCC_WARN_UNDECLARED_SELECTOR = YES; 364 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 365 | GCC_WARN_UNUSED_FUNCTION = YES; 366 | GCC_WARN_UNUSED_VARIABLE = YES; 367 | IPHONEOS_DEPLOYMENT_TARGET = 11.2; 368 | MTL_ENABLE_DEBUG_INFO = NO; 369 | SDKROOT = iphoneos; 370 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 371 | VALIDATE_PRODUCT = YES; 372 | }; 373 | name = Release; 374 | }; 375 | 82680F48206C91C000A1277F /* Debug */ = { 376 | isa = XCBuildConfiguration; 377 | baseConfigurationReference = 26110AF74EF70126A1BCCADB /* Pods-AvatarCapture.debug.xcconfig */; 378 | buildSettings = { 379 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 380 | CODE_SIGN_STYLE = Automatic; 381 | INFOPLIST_FILE = AvatarCapture/Info.plist; 382 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 383 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 384 | PRODUCT_BUNDLE_IDENTIFIER = com.gatewayapps.AvatarCapture; 385 | PRODUCT_NAME = "$(TARGET_NAME)"; 386 | SWIFT_VERSION = 4.0; 387 | TARGETED_DEVICE_FAMILY = "1,2"; 388 | }; 389 | name = Debug; 390 | }; 391 | 82680F49206C91C000A1277F /* Release */ = { 392 | isa = XCBuildConfiguration; 393 | baseConfigurationReference = 7C6D0ECC02A771FE47E81BD3 /* Pods-AvatarCapture.release.xcconfig */; 394 | buildSettings = { 395 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 396 | CODE_SIGN_STYLE = Automatic; 397 | INFOPLIST_FILE = AvatarCapture/Info.plist; 398 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 399 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 400 | PRODUCT_BUNDLE_IDENTIFIER = com.gatewayapps.AvatarCapture; 401 | PRODUCT_NAME = "$(TARGET_NAME)"; 402 | SWIFT_VERSION = 4.0; 403 | TARGETED_DEVICE_FAMILY = "1,2"; 404 | }; 405 | name = Release; 406 | }; 407 | /* End XCBuildConfiguration section */ 408 | 409 | /* Begin XCConfigurationList section */ 410 | 82680F30206C91C000A1277F /* Build configuration list for PBXProject "AvatarCapture" */ = { 411 | isa = XCConfigurationList; 412 | buildConfigurations = ( 413 | 82680F45206C91C000A1277F /* Debug */, 414 | 82680F46206C91C000A1277F /* Release */, 415 | ); 416 | defaultConfigurationIsVisible = 0; 417 | defaultConfigurationName = Release; 418 | }; 419 | 82680F47206C91C000A1277F /* Build configuration list for PBXNativeTarget "AvatarCapture" */ = { 420 | isa = XCConfigurationList; 421 | buildConfigurations = ( 422 | 82680F48206C91C000A1277F /* Debug */, 423 | 82680F49206C91C000A1277F /* Release */, 424 | ); 425 | defaultConfigurationIsVisible = 0; 426 | defaultConfigurationName = Release; 427 | }; 428 | /* End XCConfigurationList section */ 429 | }; 430 | rootObject = 82680F2D206C91C000A1277F /* Project object */; 431 | } 432 | -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // AvatarCapture 4 | // 5 | // Created by John Murphy on 3/28/18. 6 | // Copyright © 2018 John Murphy. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // 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. 24 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // 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. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // 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. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture/Assets.xcassets/Capture/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture/Assets.xcassets/Capture/close.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "close.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "close@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "close@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture/Assets.xcassets/Capture/close.imageset/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gatewayapps/avatar-capture-ios/bbd91b5f90da7810968c2d10276f597ac7b21917/AvatarCapture/AvatarCapture/Assets.xcassets/Capture/close.imageset/close.png -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture/Assets.xcassets/Capture/close.imageset/close@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gatewayapps/avatar-capture-ios/bbd91b5f90da7810968c2d10276f597ac7b21917/AvatarCapture/AvatarCapture/Assets.xcassets/Capture/close.imageset/close@2x.png -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture/Assets.xcassets/Capture/close.imageset/close@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gatewayapps/avatar-capture-ios/bbd91b5f90da7810968c2d10276f597ac7b21917/AvatarCapture/AvatarCapture/Assets.xcassets/Capture/close.imageset/close@3x.png -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture/Assets.xcassets/Capture/flash.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "flash.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "flash@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture/Assets.xcassets/Capture/flash.imageset/flash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gatewayapps/avatar-capture-ios/bbd91b5f90da7810968c2d10276f597ac7b21917/AvatarCapture/AvatarCapture/Assets.xcassets/Capture/flash.imageset/flash.png -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture/Assets.xcassets/Capture/flash.imageset/flash@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gatewayapps/avatar-capture-ios/bbd91b5f90da7810968c2d10276f597ac7b21917/AvatarCapture/AvatarCapture/Assets.xcassets/Capture/flash.imageset/flash@2x.png -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture/Assets.xcassets/Capture/flashselected.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "flashselected.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "flashselected@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture/Assets.xcassets/Capture/flashselected.imageset/flashselected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gatewayapps/avatar-capture-ios/bbd91b5f90da7810968c2d10276f597ac7b21917/AvatarCapture/AvatarCapture/Assets.xcassets/Capture/flashselected.imageset/flashselected.png -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture/Assets.xcassets/Capture/flashselected.imageset/flashselected@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gatewayapps/avatar-capture-ios/bbd91b5f90da7810968c2d10276f597ac7b21917/AvatarCapture/AvatarCapture/Assets.xcassets/Capture/flashselected.imageset/flashselected@2x.png -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture/Assets.xcassets/Capture/front-camera.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "front-camera.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "front-camera@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture/Assets.xcassets/Capture/front-camera.imageset/front-camera.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gatewayapps/avatar-capture-ios/bbd91b5f90da7810968c2d10276f597ac7b21917/AvatarCapture/AvatarCapture/Assets.xcassets/Capture/front-camera.imageset/front-camera.png -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture/Assets.xcassets/Capture/front-camera.imageset/front-camera@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gatewayapps/avatar-capture-ios/bbd91b5f90da7810968c2d10276f597ac7b21917/AvatarCapture/AvatarCapture/Assets.xcassets/Capture/front-camera.imageset/front-camera@2x.png -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture/Assets.xcassets/Capture/library.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "library.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "library@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture/Assets.xcassets/Capture/library.imageset/library.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gatewayapps/avatar-capture-ios/bbd91b5f90da7810968c2d10276f597ac7b21917/AvatarCapture/AvatarCapture/Assets.xcassets/Capture/library.imageset/library.png -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture/Assets.xcassets/Capture/library.imageset/library@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gatewayapps/avatar-capture-ios/bbd91b5f90da7810968c2d10276f597ac7b21917/AvatarCapture/AvatarCapture/Assets.xcassets/Capture/library.imageset/library@2x.png -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture/Assets.xcassets/Capture/selected.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "selected.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "selected@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture/Assets.xcassets/Capture/selected.imageset/selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gatewayapps/avatar-capture-ios/bbd91b5f90da7810968c2d10276f597ac7b21917/AvatarCapture/AvatarCapture/Assets.xcassets/Capture/selected.imageset/selected.png -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture/Assets.xcassets/Capture/selected.imageset/selected@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gatewayapps/avatar-capture-ios/bbd91b5f90da7810968c2d10276f597ac7b21917/AvatarCapture/AvatarCapture/Assets.xcassets/Capture/selected.imageset/selected@2x.png -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture/Assets.xcassets/Capture/shutter.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "shutter.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "shutter@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "shutter@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture/Assets.xcassets/Capture/shutter.imageset/shutter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gatewayapps/avatar-capture-ios/bbd91b5f90da7810968c2d10276f597ac7b21917/AvatarCapture/AvatarCapture/Assets.xcassets/Capture/shutter.imageset/shutter.png -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture/Assets.xcassets/Capture/shutter.imageset/shutter@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gatewayapps/avatar-capture-ios/bbd91b5f90da7810968c2d10276f597ac7b21917/AvatarCapture/AvatarCapture/Assets.xcassets/Capture/shutter.imageset/shutter@2x.png -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture/Assets.xcassets/Capture/shutter.imageset/shutter@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gatewayapps/avatar-capture-ios/bbd91b5f90da7810968c2d10276f597ac7b21917/AvatarCapture/AvatarCapture/Assets.xcassets/Capture/shutter.imageset/shutter@3x.png -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture/AvatarCaptureController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AvatarCaptureController.swift 3 | // AvatarCapture 4 | // 5 | // Created by John Murphy on 3/28/18. 6 | // Copyright © 2018 John Murphy. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import QuartzCore 11 | import AVFoundation 12 | import FontAwesome_swift 13 | 14 | public protocol AvatarCaptureControllerDelegate: NSObjectProtocol { 15 | func imageSelected(image: UIImage) 16 | func imageSelectionCancelled() 17 | } 18 | 19 | open class AvatarCaptureController: UIViewController { 20 | public var delegate: AvatarCaptureControllerDelegate? 21 | public var image: UIImage? 22 | 23 | var previousFrame: CGRect? 24 | var isCapturing: Bool? 25 | var avatarView: UIImageView? 26 | var captureView: UIView? 27 | var captureSession: AVCaptureSession? 28 | var stillImageOutput: AVCapturePhotoOutput? 29 | var captureDevice: AVCaptureDevice? 30 | var captureVideoPreviewLayer: AVCaptureVideoPreviewLayer? 31 | var isCapturingImage: Bool? 32 | var capturedImageView: UIImageView? 33 | var picker: UIImagePickerController? 34 | var imageSelectedView: UIView? 35 | var selectedImage: UIImage? 36 | var resourceBundle: Bundle? 37 | 38 | // MARK: View Controller Overrides 39 | override open func viewDidLoad() { 40 | super.viewDidLoad() 41 | 42 | // Do any additional setup after loading the view. 43 | isCapturing = false 44 | 45 | let singleTapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(startCapture)) 46 | view.addGestureRecognizer(singleTapGestureRecognizer) 47 | 48 | // initialize the avatar view 49 | avatarView = UIImageView.init(frame: view.frame) 50 | avatarView?.image = image 51 | avatarView?.autoresizingMask = UIViewAutoresizing(rawValue: UIViewAutoresizing.RawValue(UInt8(UIViewAutoresizing.flexibleHeight.rawValue) | UInt8(UIViewAutoresizing.flexibleWidth.rawValue))) 52 | avatarView?.contentMode = .scaleAspectFill 53 | avatarView?.layer.masksToBounds = true 54 | avatarView?.layer.cornerRadius = view.bounds.width / 2 55 | view.addSubview(avatarView!) 56 | 57 | // get the resource bundle 58 | let frameworkBundle = Bundle(for: AvatarCaptureController.self) 59 | let bundleUrl = frameworkBundle.resourceURL?.appendingPathComponent("AvatarCapture.bundle") 60 | resourceBundle = Bundle(url: bundleUrl!) 61 | } 62 | 63 | override open func viewWillLayoutSubviews() { 64 | super.viewWillLayoutSubviews() 65 | 66 | view.frame = (view.superview?.bounds)! 67 | view.layer.cornerRadius = view.bounds.width / 2 68 | avatarView?.layer.cornerRadius = view.bounds.width / 2 69 | } 70 | 71 | override open func didReceiveMemoryWarning() { 72 | super.didReceiveMemoryWarning() 73 | // Dispose of any resources that can be recreated. 74 | } 75 | 76 | // MARK: Exposed methods 77 | @objc open func startCapture() { 78 | if isCapturing! { 79 | return 80 | } 81 | 82 | isCapturing = true 83 | for subView in view.subviews { 84 | subView.removeFromSuperview() 85 | } 86 | previousFrame = view.convert(view.frame, to: nil) 87 | 88 | initializeCaptureView() 89 | 90 | if let device = getCaptureDevice() { 91 | let input = try? AVCaptureDeviceInput.init(device: device) 92 | 93 | if let input = input { 94 | captureSession?.addInput(input) 95 | 96 | stillImageOutput = AVCapturePhotoOutput() 97 | captureSession?.addOutput(stillImageOutput!) 98 | 99 | addCameraControls() 100 | } 101 | } 102 | 103 | addOtherControls() 104 | 105 | captureSession?.startRunning() 106 | } 107 | 108 | open func endCapture() { 109 | captureSession?.stopRunning() 110 | 111 | captureVideoPreviewLayer?.removeFromSuperlayer() 112 | for subview in (captureView?.subviews)! { 113 | subview.removeFromSuperview() 114 | } 115 | 116 | avatarView = UIImageView.init(frame: CGRect(x: 0, 117 | y: 0, 118 | width: (previousFrame?.width)!, 119 | height: (previousFrame?.height)!)) 120 | avatarView?.image = image 121 | avatarView?.contentMode = .scaleAspectFill 122 | avatarView?.layer.masksToBounds = true 123 | avatarView?.layer.cornerRadius = (avatarView?.frame.width)! / 2 124 | 125 | view.addSubview(avatarView!) 126 | view.layer.cornerRadius = view.frame.width / 2 127 | 128 | captureView?.removeFromSuperview() 129 | isCapturing = false 130 | } 131 | 132 | @objc open func swapCameras() { 133 | if isCapturingImage != true { 134 | let deviceDiscoverySession = AVCaptureDevice.DiscoverySession.init(deviceTypes: [.builtInWideAngleCamera], mediaType: .video, position: .unspecified) 135 | 136 | if captureDevice?.position == AVCaptureDevice.Position.back { 137 | for device in deviceDiscoverySession.devices { 138 | if device.position == .front { 139 | captureDevice = device 140 | break 141 | } 142 | } 143 | } else if captureDevice?.position == AVCaptureDevice.Position.front { 144 | for device in deviceDiscoverySession.devices { 145 | if device.position == .back { 146 | captureDevice = device 147 | break 148 | } 149 | } 150 | } 151 | 152 | captureSession?.beginConfiguration() 153 | let newInput = try? AVCaptureDeviceInput (device: captureDevice!) 154 | for oldInput in (captureSession?.inputs)! { 155 | captureSession?.removeInput(oldInput) 156 | } 157 | captureSession?.addInput(newInput!) 158 | captureSession?.commitConfiguration() 159 | } 160 | } 161 | 162 | @objc open func showImagePicker() { 163 | picker = UIImagePickerController() 164 | picker?.sourceType = .photoLibrary 165 | picker?.delegate = self 166 | present(picker!, animated: true, completion: nil) 167 | } 168 | 169 | // MARK: Private methods 170 | func addOtherControls() { 171 | // library picker button 172 | var showImagePickerButton = UIButton(frame: CGRect(x:(view.window?.frame.width)! - 40, 173 | y: (view.window?.frame.height)! - 40 - 27, 174 | width: 27, 175 | height: 27)) 176 | showImagePickerButton = setButtonProperties(button: showImagePickerButton, fontSize: 27, icon: .clone, selector: #selector(showImagePicker)) 177 | captureView?.addSubview(showImagePickerButton) 178 | 179 | // cancel button 180 | var cancelButton = UIButton(frame: CGRect(x:view.frame.origin.x + 20, 181 | y: view.frame.origin.y + 40, 182 | width: 32, 183 | height: 32)) 184 | cancelButton = setButtonProperties(button: cancelButton, fontSize: 32, icon: .close, selector: #selector(cancel)) 185 | captureView?.addSubview(cancelButton) 186 | 187 | imageSelectedView = UIView.init(frame: (captureView?.frame)!) 188 | imageSelectedView?.backgroundColor = UIColor.clear 189 | imageSelectedView?.addSubview(capturedImageView!) 190 | 191 | let overlayView = UIView.init(frame: CGRect(x: 0, 192 | y: (previousFrame?.origin.y)! + (previousFrame?.height)!, 193 | width: (captureView?.frame.width)!, 194 | height: 60)) 195 | imageSelectedView?.addSubview(overlayView) 196 | 197 | var selectPhotoButton = UIButton(frame: CGRect(x:(previousFrame?.origin.x)!, 198 | y: 0, 199 | width: 32, 200 | height: 32)) 201 | selectPhotoButton = setButtonProperties(button: selectPhotoButton, fontSize: 32, icon: .check, selector: #selector(photoSelected)) 202 | overlayView.addSubview(selectPhotoButton) 203 | 204 | var cancelSelectPhotoButton = UIButton(frame: CGRect(x:(previousFrame?.origin.x)! + (previousFrame?.width)! - 32, 205 | y: 0, 206 | width: 32, 207 | height: 32)) 208 | cancelSelectPhotoButton = setButtonProperties(button: cancelSelectPhotoButton, fontSize: 32, icon: .close, selector: #selector(cancelSelectedPhoto)) 209 | overlayView.addSubview(cancelSelectPhotoButton) 210 | } 211 | 212 | func addCameraControls() { 213 | // shutter button 214 | let shutterButton = UIButton(frame: CGRect(x:(previousFrame?.origin.x)! + ((previousFrame?.width)! / 2)-50, 215 | y: (view.window?.frame.height)! - 40 - 100, 216 | width: 100, 217 | height: 100)) 218 | 219 | shutterButton.setImage(UIImage(named: "shutter", in: resourceBundle, compatibleWith: nil), for: .normal) 220 | shutterButton.addTarget(self, action: #selector(capturePhoto), for: .touchUpInside) 221 | shutterButton.layer.cornerRadius = 20 222 | captureView?.addSubview(shutterButton) 223 | 224 | // render swap camera 225 | var swapCamerasButton = UIButton(frame: CGRect(x:view.frame.origin.x + 20, 226 | y: (view.window?.frame.height)! - 40 - 25, 227 | width: 47, 228 | height: 25)) 229 | 230 | swapCamerasButton = setButtonProperties(button: swapCamerasButton, fontSize: 25, icon: .refresh, selector: #selector(swapCameras)) 231 | captureView?.addSubview(swapCamerasButton) 232 | } 233 | 234 | func setButtonProperties(button: UIButton, fontSize: Int, icon: FontAwesome, selector: Selector) -> UIButton { 235 | button.addTarget(self, action: selector, for: .touchUpInside) 236 | button.titleLabel?.font = UIFont.fontAwesome(ofSize: CGFloat(fontSize)) 237 | button.setTitleColor(UIColor.white, for: .normal) 238 | button.setTitleColor(UIColor.gray, for: .highlighted) 239 | button.setTitle(String.fontAwesomeIcon(name: icon), for: .normal) 240 | 241 | return button 242 | } 243 | 244 | func getCaptureDevice() -> AVCaptureDevice? { 245 | let deviceDiscoverySession = AVCaptureDevice.DiscoverySession.init(deviceTypes: [.builtInWideAngleCamera], mediaType: .video, position: .front) 246 | 247 | for device in deviceDiscoverySession.devices { 248 | if device.position == .front { 249 | captureDevice = device 250 | return device 251 | } 252 | } 253 | 254 | return nil 255 | } 256 | 257 | func initializeCaptureView() { 258 | captureView = UIView(frame: (view.window?.frame)!) 259 | view.window?.addSubview(captureView!) 260 | 261 | let shadeView = UIView(frame: (captureView?.frame)!) 262 | shadeView.alpha = 0.85 263 | shadeView.backgroundColor = UIColor.black 264 | captureView?.addSubview(shadeView) 265 | 266 | captureSession = AVCaptureSession() 267 | captureSession?.sessionPreset = .photo 268 | 269 | capturedImageView = UIImageView() 270 | capturedImageView?.frame = previousFrame! 271 | capturedImageView?.layer.cornerRadius = (previousFrame?.width)! / 2 272 | capturedImageView?.layer.masksToBounds = true 273 | capturedImageView?.backgroundColor = UIColor.clear 274 | capturedImageView?.isUserInteractionEnabled = true 275 | capturedImageView?.contentMode = .scaleAspectFill 276 | 277 | captureVideoPreviewLayer = AVCaptureVideoPreviewLayer(session: captureSession!) 278 | captureVideoPreviewLayer?.videoGravity = .resizeAspectFill 279 | captureVideoPreviewLayer?.frame = previousFrame! 280 | captureVideoPreviewLayer?.cornerRadius = (captureVideoPreviewLayer?.frame.width)! / 2 281 | captureView?.layer.addSublayer(captureVideoPreviewLayer!) 282 | } 283 | 284 | @objc func capturePhoto() { 285 | isCapturingImage = true 286 | 287 | let outputSettings = AVCapturePhotoSettings() 288 | 289 | if let _ = stillImageOutput?.connection(with: .video){ 290 | stillImageOutput?.setPreparedPhotoSettingsArray([AVCapturePhotoSettings(format:[AVVideoCodecKey:AVVideoCodecJPEG])], completionHandler: nil) 291 | stillImageOutput?.capturePhoto(with: outputSettings, delegate: self) 292 | } 293 | } 294 | 295 | @objc func photoSelected() { 296 | image = selectedImage! 297 | endCapture() 298 | delegate?.imageSelected(image: image!) 299 | } 300 | 301 | @objc func cancelSelectedPhoto() { 302 | imageSelectedView?.removeFromSuperview() 303 | for view in (captureView?.subviews)! { 304 | if view.isKind(of: UIButton.self) { 305 | view.isHidden = false 306 | } 307 | } 308 | } 309 | 310 | @objc func cancel() { 311 | endCapture() 312 | delegate?.imageSelectionCancelled() 313 | } 314 | } 315 | 316 | // MARK: Delegates 317 | extension AvatarCaptureController: UINavigationControllerDelegate { 318 | 319 | } 320 | 321 | extension AvatarCaptureController: UIImagePickerControllerDelegate { 322 | public func imagePickerControllerDidCancel(_ picker: UIImagePickerController) { 323 | dismiss(animated: true, completion: nil) 324 | } 325 | 326 | public func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) { 327 | selectedImage = info[UIImagePickerControllerOriginalImage] as? UIImage 328 | self.capturedImageView?.image = selectedImage 329 | 330 | dismiss(animated: true, completion: {() -> Void in 331 | for view in (self.captureView?.subviews)! { 332 | if view.isKind(of: UIButton.self) { 333 | view.isHidden = true 334 | } 335 | } 336 | self.captureView?.addSubview(self.imageSelectedView!) 337 | }) 338 | } 339 | } 340 | 341 | extension AvatarCaptureController: AVCapturePhotoCaptureDelegate { 342 | public func photoOutput(_ output: AVCapturePhotoOutput, didFinishProcessingPhoto photoSampleBuffer: CMSampleBuffer?, previewPhoto previewPhotoSampleBuffer: CMSampleBuffer?, resolvedSettings: AVCaptureResolvedPhotoSettings, bracketSettings: AVCaptureBracketedStillImageSettings?, error: Error?) { 343 | if let error = error { 344 | print(error.localizedDescription) 345 | } 346 | 347 | if let sampleBuffer = photoSampleBuffer, let dataImage = AVCapturePhotoOutput.jpegPhotoDataRepresentation(forJPEGSampleBuffer: sampleBuffer, previewPhotoSampleBuffer: sampleBuffer) { 348 | let isFrontFacing = captureDevice?.position == AVCaptureDevice.Position.front 349 | 350 | var capturedImage = UIImage.init(data: dataImage, scale:1) 351 | 352 | if isFrontFacing { 353 | capturedImage = UIImage.init(cgImage: (capturedImage?.cgImage!)!, scale: (capturedImage?.scale)!, orientation: UIImageOrientation.leftMirrored) 354 | } 355 | 356 | isCapturingImage = false 357 | capturedImageView?.image = capturedImage 358 | for view in (captureView?.subviews)! { 359 | if view.isKind(of: UIButton.self) { 360 | view.isHidden = true 361 | } 362 | } 363 | 364 | captureView?.addSubview(imageSelectedView!) 365 | selectedImage = capturedImage 366 | } 367 | } 368 | } 369 | 370 | -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture/Example/MainViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MainViewController.swift 3 | // AvatarCapture 4 | // 5 | // Created by John Murphy on 3/28/18. 6 | // Copyright © 2018 John Murphy. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class MainViewController: UIViewController { 12 | override func viewDidLoad() { 13 | super.viewDidLoad() 14 | 15 | // Do any additional setup after loading the view. 16 | let avatarCaptureController = AvatarCaptureController() 17 | avatarCaptureController.delegate = self 18 | avatarCaptureController.image = UIImage.init(named: "chin.png") 19 | avatarView.addSubview((avatarCaptureController.view)!) 20 | } 21 | 22 | override func didReceiveMemoryWarning() { 23 | super.didReceiveMemoryWarning() 24 | // Dispose of any resources that can be recreated. 25 | } 26 | } 27 | 28 | extension MainViewController: AvatarCaptureControllerDelegate { 29 | func imageSelected(image: UIImage) { 30 | print("image Selected") 31 | } 32 | 33 | func imageSelectionCancelled() { 34 | print("image selection cancelled") 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture/Example/chin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gatewayapps/avatar-capture-ios/bbd91b5f90da7810968c2d10276f597ac7b21917/AvatarCapture/AvatarCapture/Example/chin.png -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | NSCameraUsageDescription 24 | Camera allowance required 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture/MainViewViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MainViewController.swift 3 | // AvatarCapture 4 | // 5 | // Created by John Murphy on 3/28/18. 6 | // Copyright © 2018 John Murphy. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class MainViewViewController: UIViewController { 12 | @IBOutlet weak var avatarView: UIView! 13 | 14 | var avatarCaptureController = AvatarCaptureController() 15 | 16 | override func viewDidLoad() { 17 | super.viewDidLoad() 18 | 19 | // Do any additional setup after loading the view. 20 | avatarCaptureController = AvatarCaptureController() 21 | avatarCaptureController.delegate = self 22 | avatarCaptureController.image = UIImage.init(named: "chin.png") 23 | avatarView.addSubview((avatarCaptureController.view)!) 24 | } 25 | 26 | @IBAction func pressed(_ sender: Any) { 27 | avatarCaptureController.startCapture() 28 | } 29 | 30 | override func didReceiveMemoryWarning() { 31 | super.didReceiveMemoryWarning() 32 | // Dispose of any resources that can be recreated. 33 | } 34 | } 35 | 36 | extension MainViewViewController: AvatarCaptureControllerDelegate { 37 | func imageSelected(image: UIImage) { 38 | print("image Selected") 39 | } 40 | 41 | func imageSelectionCancelled() { 42 | print("image selection cancelled") 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture/New Group/chin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gatewayapps/avatar-capture-ios/bbd91b5f90da7810968c2d10276f597ac7b21917/AvatarCapture/AvatarCapture/New Group/chin.png -------------------------------------------------------------------------------- /AvatarCapture/AvatarCapture/capture_me.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gatewayapps/avatar-capture-ios/bbd91b5f90da7810968c2d10276f597ac7b21917/AvatarCapture/AvatarCapture/capture_me.gif -------------------------------------------------------------------------------- /AvatarCapture/Podfile: -------------------------------------------------------------------------------- 1 | # Define a global platform for your project 2 | source 'https://github.com/CocoaPods/Specs.git' 3 | platform :ios, '10.0' 4 | 5 | # Uncomment this line if you're using Swift 6 | use_frameworks! 7 | 8 | target 'AvatarCapture' do 9 | pod 'FontAwesome.swift' 10 | end -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Gateway Apps 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## What is AvatarCapture? 2 | Writing a ground-up solution for taking profile pictures in iOS can be a pain and time consuming. AvatarCapture is a Swift based library inspired by [ZCSAvatarCapture](https://github.com/zshannon/ZCSAvatarCapture) whose purpose is to make it as easy as possible to start your camera(front facing or rear), allow you to snap a photo or choose a photo from your Photos library. 3 | 4 | ## Installation 5 | Note: AvatarCapture has a minimum deployment target of iOS 10 6 | 7 | Edit your PodFile: 8 | `pod 'AvatarCapture'` 9 | 10 | Then run `pod install` 11 | 12 | ## Features 13 | - Display an existing `UIImage` 14 | - Start the iPhone camera for capture 15 | - Swap cameras from front facing to rear and vice versa 16 | - Choose a photo from the iPhone library 17 | 18 | ## Plans 19 | - allow more flexibility in where buttons are positioned 20 | - add custom elements/subviews 21 | - Change/choose shape of avatar profile 22 | 23 | ## Getting Started 24 | Getting started with AvatarCapture is super easy! 25 | 26 | First, initialize the view controller(anywhere but `viewDidLoad` is common): 27 | ``` 28 | let avatarCaptureController = AvatarCaptureController() 29 | avatarCaptureController.delegate = self 30 | avatarCaptureController.image = UIImage.init(named: "an_existing_image.png") 31 | avatarView.addSubview((avatarCaptureController?.view)!) 32 | ``` 33 | 34 | `AvatarCaptureController` subscribes to `AvatarCaptureControllerDelegate` and is required for retrieving the UIImage after selecting a photo 35 | 36 | In this example, `avatarView` is a UIView defined in a storyboard. Whatever the `width` and `height` of this UIView is will determine the dimensions of the avatar. 37 | 38 | ## Helper Methods 39 | `startCapture()` - Begins capturing the output from your iPhone camera and displays the on screen buttons to interact with your camera 40 | `endCapture()` - Stops the live preview of the iPhone camera. This method does not need to be explicitly called in most situations 41 | `swapCameras()` - Swaps the live preview from the front to rear camera and vice versa. This method does not need to be explicitly called in most situations. 42 | `showImagePicker()` - Displays the Photos library for choosing an image 43 | 44 | ## How do I get my image? 45 | Once you've subscribed to the `AvatarCaptureControllerDelegate` protocol, you can be notified when an image was selected and when the image selection was cancelled: 46 | 47 | ``` 48 | extension MyViewController: AvatarCaptureControllerDelegate { 49 | func imageSelected(image: UIImage) { 50 | print("image Selected") 51 | } 52 | 53 | func imageSelectionCancelled() { 54 | print("image selection cancelled") 55 | } 56 | } 57 | ``` 58 | 59 | ## AvatarCapture In Action 60 | Don't I look excited...? 61 | ![Capture](https://github.com/gatewayapps/avatar-capture-ios/blob/master/AvatarCapture/AvatarCapture/capture_me.gif) 62 | 63 | ## Thanks 64 | **Berend Ozceri** - [@berendo](https://github.com/berendo) for thinking of doing this 65 | [ZCSAvatarCapture](https://github.com/zshannon/ZCSAvatarCapture) for doing this first 66 | 67 | ## Feedback 68 | Please feel free to create issues if bugs are found or if enhancements or new features are desired 69 | --------------------------------------------------------------------------------