├── README.md ├── ScanCode.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── gaofu.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── gaofu.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── ScanCode.xcscheme │ └── xcschememanagement.plist └── ScanCode ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets └── AppIcon.appiconset │ └── Contents.json ├── Base.lproj ├── LaunchScreen.storyboard └── Main.storyboard ├── Info.plist ├── MyQRCodeViewController.h ├── MyQRCodeViewController.m ├── Pictures.xcassets ├── Contents.json ├── headerimage.imageset │ ├── Contents.json │ ├── headerimage@2x.png │ └── headerimage@3x.png ├── scancode_box.imageset │ ├── Contents.json │ ├── scancode_box@2x.png │ └── scancode_box@3x.png ├── scancode_light.imageset │ ├── Contents.json │ ├── scancode_light@2x.png │ └── scancode_light@3x.png ├── scancode_light_select.imageset │ ├── Contents.json │ ├── scancode_light_select@2x.png │ └── scancode_light_select@3x.png ├── scancode_line.imageset │ ├── Contents.json │ ├── scancode_line@2x.png │ └── scancode_line@3x.png ├── scancode_myqrcode.imageset │ ├── Contents.json │ ├── scancode_myqrcode@2x.png │ └── scancode_myqrcode@3x.png └── scancode_photo.imageset │ ├── Contents.json │ ├── scancode_photo@2x.png │ └── scancode_photo@3x.png ├── ScanCode ├── NSString+QRCode.h ├── NSString+QRCode.m ├── UIImage+Extend.h └── UIImage+Extend.m ├── ScanCodeViewController.h ├── ScanCodeViewController.m ├── main.m ├── scancode.caf └── zh-Hans.lproj ├── LaunchScreen.strings └── Main.strings /README.md: -------------------------------------------------------------------------------- 1 | # ScanCode 2 | 二维码识别,生成,扫描(优化启动卡顿) 3 | 4 | 请查看我的[博客](http://www.jianshu.com/p/f9141f5fd6b6) 5 | 6 | -------------------------------------------------------------------------------- /ScanCode.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | FD2762F51EA8B4600066E7A8 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = FD2762F41EA8B4600066E7A8 /* main.m */; }; 11 | FD2762F81EA8B4600066E7A8 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = FD2762F71EA8B4600066E7A8 /* AppDelegate.m */; }; 12 | FD2762FE1EA8B4600066E7A8 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FD2762FC1EA8B4600066E7A8 /* Main.storyboard */; }; 13 | FD2763001EA8B4600066E7A8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FD2762FF1EA8B4600066E7A8 /* Assets.xcassets */; }; 14 | FD2763031EA8B4600066E7A8 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FD2763011EA8B4600066E7A8 /* LaunchScreen.storyboard */; }; 15 | FD27630B1EA8B4B30066E7A8 /* Pictures.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FD27630A1EA8B4B30066E7A8 /* Pictures.xcassets */; }; 16 | FD2763101EA8B6590066E7A8 /* MyQRCodeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FD27630D1EA8B6590066E7A8 /* MyQRCodeViewController.m */; }; 17 | FD2763111EA8B6590066E7A8 /* ScanCodeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FD27630F1EA8B6590066E7A8 /* ScanCodeViewController.m */; }; 18 | FD2763191EA8B8030066E7A8 /* scancode.caf in Resources */ = {isa = PBXBuildFile; fileRef = FD2763181EA8B8030066E7A8 /* scancode.caf */; }; 19 | FD2763211EA8BDDD0066E7A8 /* NSString+QRCode.m in Sources */ = {isa = PBXBuildFile; fileRef = FD27631E1EA8BDDD0066E7A8 /* NSString+QRCode.m */; }; 20 | FD2763221EA8BDDD0066E7A8 /* UIImage+Extend.m in Sources */ = {isa = PBXBuildFile; fileRef = FD2763201EA8BDDD0066E7A8 /* UIImage+Extend.m */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXFileReference section */ 24 | FD2762F01EA8B4600066E7A8 /* ScanCode.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ScanCode.app; sourceTree = BUILT_PRODUCTS_DIR; }; 25 | FD2762F41EA8B4600066E7A8 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 26 | FD2762F61EA8B4600066E7A8 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 27 | FD2762F71EA8B4600066E7A8 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 28 | FD2762FD1EA8B4600066E7A8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 29 | FD2762FF1EA8B4600066E7A8 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 30 | FD2763021EA8B4600066E7A8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 31 | FD2763041EA8B4600066E7A8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 32 | FD27630A1EA8B4B30066E7A8 /* Pictures.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Pictures.xcassets; sourceTree = ""; }; 33 | FD27630C1EA8B6590066E7A8 /* MyQRCodeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MyQRCodeViewController.h; sourceTree = ""; }; 34 | FD27630D1EA8B6590066E7A8 /* MyQRCodeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MyQRCodeViewController.m; sourceTree = ""; }; 35 | FD27630E1EA8B6590066E7A8 /* ScanCodeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScanCodeViewController.h; sourceTree = ""; }; 36 | FD27630F1EA8B6590066E7A8 /* ScanCodeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ScanCodeViewController.m; sourceTree = ""; }; 37 | FD2763181EA8B8030066E7A8 /* scancode.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = scancode.caf; sourceTree = ""; }; 38 | FD27631A1EA8B8A50066E7A8 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Main.strings"; sourceTree = ""; }; 39 | FD27631B1EA8B8A50066E7A8 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/LaunchScreen.strings"; sourceTree = ""; }; 40 | FD27631D1EA8BDDD0066E7A8 /* NSString+QRCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+QRCode.h"; sourceTree = ""; }; 41 | FD27631E1EA8BDDD0066E7A8 /* NSString+QRCode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+QRCode.m"; sourceTree = ""; }; 42 | FD27631F1EA8BDDD0066E7A8 /* UIImage+Extend.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+Extend.h"; sourceTree = ""; }; 43 | FD2763201EA8BDDD0066E7A8 /* UIImage+Extend.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+Extend.m"; sourceTree = ""; }; 44 | /* End PBXFileReference section */ 45 | 46 | /* Begin PBXFrameworksBuildPhase section */ 47 | FD2762ED1EA8B4600066E7A8 /* Frameworks */ = { 48 | isa = PBXFrameworksBuildPhase; 49 | buildActionMask = 2147483647; 50 | files = ( 51 | ); 52 | runOnlyForDeploymentPostprocessing = 0; 53 | }; 54 | /* End PBXFrameworksBuildPhase section */ 55 | 56 | /* Begin PBXGroup section */ 57 | FD2762E71EA8B4600066E7A8 = { 58 | isa = PBXGroup; 59 | children = ( 60 | FD2762F21EA8B4600066E7A8 /* ScanCode */, 61 | FD2762F11EA8B4600066E7A8 /* Products */, 62 | ); 63 | sourceTree = ""; 64 | }; 65 | FD2762F11EA8B4600066E7A8 /* Products */ = { 66 | isa = PBXGroup; 67 | children = ( 68 | FD2762F01EA8B4600066E7A8 /* ScanCode.app */, 69 | ); 70 | name = Products; 71 | sourceTree = ""; 72 | }; 73 | FD2762F21EA8B4600066E7A8 /* ScanCode */ = { 74 | isa = PBXGroup; 75 | children = ( 76 | FD27631C1EA8BDDD0066E7A8 /* ScanCode */, 77 | FD2762F61EA8B4600066E7A8 /* AppDelegate.h */, 78 | FD2762F71EA8B4600066E7A8 /* AppDelegate.m */, 79 | FD27630C1EA8B6590066E7A8 /* MyQRCodeViewController.h */, 80 | FD27630D1EA8B6590066E7A8 /* MyQRCodeViewController.m */, 81 | FD27630E1EA8B6590066E7A8 /* ScanCodeViewController.h */, 82 | FD27630F1EA8B6590066E7A8 /* ScanCodeViewController.m */, 83 | FD2762FC1EA8B4600066E7A8 /* Main.storyboard */, 84 | FD2763181EA8B8030066E7A8 /* scancode.caf */, 85 | FD2762FF1EA8B4600066E7A8 /* Assets.xcassets */, 86 | FD2763011EA8B4600066E7A8 /* LaunchScreen.storyboard */, 87 | FD2763041EA8B4600066E7A8 /* Info.plist */, 88 | FD2762F31EA8B4600066E7A8 /* Supporting Files */, 89 | FD27630A1EA8B4B30066E7A8 /* Pictures.xcassets */, 90 | ); 91 | path = ScanCode; 92 | sourceTree = ""; 93 | }; 94 | FD2762F31EA8B4600066E7A8 /* Supporting Files */ = { 95 | isa = PBXGroup; 96 | children = ( 97 | FD2762F41EA8B4600066E7A8 /* main.m */, 98 | ); 99 | name = "Supporting Files"; 100 | sourceTree = ""; 101 | }; 102 | FD27631C1EA8BDDD0066E7A8 /* ScanCode */ = { 103 | isa = PBXGroup; 104 | children = ( 105 | FD27631D1EA8BDDD0066E7A8 /* NSString+QRCode.h */, 106 | FD27631E1EA8BDDD0066E7A8 /* NSString+QRCode.m */, 107 | FD27631F1EA8BDDD0066E7A8 /* UIImage+Extend.h */, 108 | FD2763201EA8BDDD0066E7A8 /* UIImage+Extend.m */, 109 | ); 110 | path = ScanCode; 111 | sourceTree = ""; 112 | }; 113 | /* End PBXGroup section */ 114 | 115 | /* Begin PBXNativeTarget section */ 116 | FD2762EF1EA8B4600066E7A8 /* ScanCode */ = { 117 | isa = PBXNativeTarget; 118 | buildConfigurationList = FD2763071EA8B4600066E7A8 /* Build configuration list for PBXNativeTarget "ScanCode" */; 119 | buildPhases = ( 120 | FD2762EC1EA8B4600066E7A8 /* Sources */, 121 | FD2762ED1EA8B4600066E7A8 /* Frameworks */, 122 | FD2762EE1EA8B4600066E7A8 /* Resources */, 123 | ); 124 | buildRules = ( 125 | ); 126 | dependencies = ( 127 | ); 128 | name = ScanCode; 129 | productName = ScanCode; 130 | productReference = FD2762F01EA8B4600066E7A8 /* ScanCode.app */; 131 | productType = "com.apple.product-type.application"; 132 | }; 133 | /* End PBXNativeTarget section */ 134 | 135 | /* Begin PBXProject section */ 136 | FD2762E81EA8B4600066E7A8 /* Project object */ = { 137 | isa = PBXProject; 138 | attributes = { 139 | LastUpgradeCheck = 0830; 140 | ORGANIZATIONNAME = gaofu; 141 | TargetAttributes = { 142 | FD2762EF1EA8B4600066E7A8 = { 143 | CreatedOnToolsVersion = 8.3; 144 | DevelopmentTeam = 6459Z37373; 145 | ProvisioningStyle = Automatic; 146 | }; 147 | }; 148 | }; 149 | buildConfigurationList = FD2762EB1EA8B4600066E7A8 /* Build configuration list for PBXProject "ScanCode" */; 150 | compatibilityVersion = "Xcode 3.2"; 151 | developmentRegion = English; 152 | hasScannedForEncodings = 0; 153 | knownRegions = ( 154 | en, 155 | Base, 156 | ); 157 | mainGroup = FD2762E71EA8B4600066E7A8; 158 | productRefGroup = FD2762F11EA8B4600066E7A8 /* Products */; 159 | projectDirPath = ""; 160 | projectRoot = ""; 161 | targets = ( 162 | FD2762EF1EA8B4600066E7A8 /* ScanCode */, 163 | ); 164 | }; 165 | /* End PBXProject section */ 166 | 167 | /* Begin PBXResourcesBuildPhase section */ 168 | FD2762EE1EA8B4600066E7A8 /* Resources */ = { 169 | isa = PBXResourcesBuildPhase; 170 | buildActionMask = 2147483647; 171 | files = ( 172 | FD2763191EA8B8030066E7A8 /* scancode.caf in Resources */, 173 | FD27630B1EA8B4B30066E7A8 /* Pictures.xcassets in Resources */, 174 | FD2763031EA8B4600066E7A8 /* LaunchScreen.storyboard in Resources */, 175 | FD2763001EA8B4600066E7A8 /* Assets.xcassets in Resources */, 176 | FD2762FE1EA8B4600066E7A8 /* Main.storyboard in Resources */, 177 | ); 178 | runOnlyForDeploymentPostprocessing = 0; 179 | }; 180 | /* End PBXResourcesBuildPhase section */ 181 | 182 | /* Begin PBXSourcesBuildPhase section */ 183 | FD2762EC1EA8B4600066E7A8 /* Sources */ = { 184 | isa = PBXSourcesBuildPhase; 185 | buildActionMask = 2147483647; 186 | files = ( 187 | FD2763211EA8BDDD0066E7A8 /* NSString+QRCode.m in Sources */, 188 | FD2763101EA8B6590066E7A8 /* MyQRCodeViewController.m in Sources */, 189 | FD2762F81EA8B4600066E7A8 /* AppDelegate.m in Sources */, 190 | FD2763111EA8B6590066E7A8 /* ScanCodeViewController.m in Sources */, 191 | FD2762F51EA8B4600066E7A8 /* main.m in Sources */, 192 | FD2763221EA8BDDD0066E7A8 /* UIImage+Extend.m in Sources */, 193 | ); 194 | runOnlyForDeploymentPostprocessing = 0; 195 | }; 196 | /* End PBXSourcesBuildPhase section */ 197 | 198 | /* Begin PBXVariantGroup section */ 199 | FD2762FC1EA8B4600066E7A8 /* Main.storyboard */ = { 200 | isa = PBXVariantGroup; 201 | children = ( 202 | FD2762FD1EA8B4600066E7A8 /* Base */, 203 | FD27631A1EA8B8A50066E7A8 /* zh-Hans */, 204 | ); 205 | name = Main.storyboard; 206 | sourceTree = ""; 207 | }; 208 | FD2763011EA8B4600066E7A8 /* LaunchScreen.storyboard */ = { 209 | isa = PBXVariantGroup; 210 | children = ( 211 | FD2763021EA8B4600066E7A8 /* Base */, 212 | FD27631B1EA8B8A50066E7A8 /* zh-Hans */, 213 | ); 214 | name = LaunchScreen.storyboard; 215 | sourceTree = ""; 216 | }; 217 | /* End PBXVariantGroup section */ 218 | 219 | /* Begin XCBuildConfiguration section */ 220 | FD2763051EA8B4600066E7A8 /* Debug */ = { 221 | isa = XCBuildConfiguration; 222 | buildSettings = { 223 | ALWAYS_SEARCH_USER_PATHS = NO; 224 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 225 | CLANG_ANALYZER_NONNULL = YES; 226 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 227 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 228 | CLANG_CXX_LIBRARY = "libc++"; 229 | CLANG_ENABLE_MODULES = YES; 230 | CLANG_ENABLE_OBJC_ARC = YES; 231 | CLANG_WARN_BOOL_CONVERSION = YES; 232 | CLANG_WARN_CONSTANT_CONVERSION = YES; 233 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 234 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 235 | CLANG_WARN_EMPTY_BODY = YES; 236 | CLANG_WARN_ENUM_CONVERSION = YES; 237 | CLANG_WARN_INFINITE_RECURSION = YES; 238 | CLANG_WARN_INT_CONVERSION = YES; 239 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 240 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 241 | CLANG_WARN_UNREACHABLE_CODE = YES; 242 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 243 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 244 | COPY_PHASE_STRIP = NO; 245 | DEBUG_INFORMATION_FORMAT = dwarf; 246 | ENABLE_STRICT_OBJC_MSGSEND = YES; 247 | ENABLE_TESTABILITY = YES; 248 | GCC_C_LANGUAGE_STANDARD = gnu99; 249 | GCC_DYNAMIC_NO_PIC = NO; 250 | GCC_NO_COMMON_BLOCKS = YES; 251 | GCC_OPTIMIZATION_LEVEL = 0; 252 | GCC_PREPROCESSOR_DEFINITIONS = ( 253 | "DEBUG=1", 254 | "$(inherited)", 255 | ); 256 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 257 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 258 | GCC_WARN_UNDECLARED_SELECTOR = YES; 259 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 260 | GCC_WARN_UNUSED_FUNCTION = YES; 261 | GCC_WARN_UNUSED_VARIABLE = YES; 262 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 263 | MTL_ENABLE_DEBUG_INFO = YES; 264 | ONLY_ACTIVE_ARCH = YES; 265 | SDKROOT = iphoneos; 266 | TARGETED_DEVICE_FAMILY = "1,2"; 267 | }; 268 | name = Debug; 269 | }; 270 | FD2763061EA8B4600066E7A8 /* Release */ = { 271 | isa = XCBuildConfiguration; 272 | buildSettings = { 273 | ALWAYS_SEARCH_USER_PATHS = NO; 274 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 275 | CLANG_ANALYZER_NONNULL = YES; 276 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 277 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 278 | CLANG_CXX_LIBRARY = "libc++"; 279 | CLANG_ENABLE_MODULES = YES; 280 | CLANG_ENABLE_OBJC_ARC = YES; 281 | CLANG_WARN_BOOL_CONVERSION = YES; 282 | CLANG_WARN_CONSTANT_CONVERSION = YES; 283 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 284 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 285 | CLANG_WARN_EMPTY_BODY = YES; 286 | CLANG_WARN_ENUM_CONVERSION = YES; 287 | CLANG_WARN_INFINITE_RECURSION = YES; 288 | CLANG_WARN_INT_CONVERSION = YES; 289 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 290 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 291 | CLANG_WARN_UNREACHABLE_CODE = YES; 292 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 293 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 294 | COPY_PHASE_STRIP = NO; 295 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 296 | ENABLE_NS_ASSERTIONS = NO; 297 | ENABLE_STRICT_OBJC_MSGSEND = YES; 298 | GCC_C_LANGUAGE_STANDARD = gnu99; 299 | GCC_NO_COMMON_BLOCKS = YES; 300 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 301 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 302 | GCC_WARN_UNDECLARED_SELECTOR = YES; 303 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 304 | GCC_WARN_UNUSED_FUNCTION = YES; 305 | GCC_WARN_UNUSED_VARIABLE = YES; 306 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 307 | MTL_ENABLE_DEBUG_INFO = NO; 308 | SDKROOT = iphoneos; 309 | TARGETED_DEVICE_FAMILY = "1,2"; 310 | VALIDATE_PRODUCT = YES; 311 | }; 312 | name = Release; 313 | }; 314 | FD2763081EA8B4600066E7A8 /* Debug */ = { 315 | isa = XCBuildConfiguration; 316 | buildSettings = { 317 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 318 | DEVELOPMENT_TEAM = 6459Z37373; 319 | INFOPLIST_FILE = ScanCode/Info.plist; 320 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 321 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 322 | PRODUCT_BUNDLE_IDENTIFIER = siruijk.com.ScanCode; 323 | PRODUCT_NAME = "$(TARGET_NAME)"; 324 | }; 325 | name = Debug; 326 | }; 327 | FD2763091EA8B4600066E7A8 /* Release */ = { 328 | isa = XCBuildConfiguration; 329 | buildSettings = { 330 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 331 | DEVELOPMENT_TEAM = 6459Z37373; 332 | INFOPLIST_FILE = ScanCode/Info.plist; 333 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 334 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 335 | PRODUCT_BUNDLE_IDENTIFIER = siruijk.com.ScanCode; 336 | PRODUCT_NAME = "$(TARGET_NAME)"; 337 | }; 338 | name = Release; 339 | }; 340 | /* End XCBuildConfiguration section */ 341 | 342 | /* Begin XCConfigurationList section */ 343 | FD2762EB1EA8B4600066E7A8 /* Build configuration list for PBXProject "ScanCode" */ = { 344 | isa = XCConfigurationList; 345 | buildConfigurations = ( 346 | FD2763051EA8B4600066E7A8 /* Debug */, 347 | FD2763061EA8B4600066E7A8 /* Release */, 348 | ); 349 | defaultConfigurationIsVisible = 0; 350 | defaultConfigurationName = Release; 351 | }; 352 | FD2763071EA8B4600066E7A8 /* Build configuration list for PBXNativeTarget "ScanCode" */ = { 353 | isa = XCConfigurationList; 354 | buildConfigurations = ( 355 | FD2763081EA8B4600066E7A8 /* Debug */, 356 | FD2763091EA8B4600066E7A8 /* Release */, 357 | ); 358 | defaultConfigurationIsVisible = 0; 359 | defaultConfigurationName = Release; 360 | }; 361 | /* End XCConfigurationList section */ 362 | }; 363 | rootObject = FD2762E81EA8B4600066E7A8 /* Project object */; 364 | } 365 | -------------------------------------------------------------------------------- /ScanCode.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ScanCode.xcodeproj/project.xcworkspace/xcuserdata/gaofu.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fuaiyi/ScanCode/825857575bbd20da3d28dd1fd3e8fb983795d30e/ScanCode.xcodeproj/project.xcworkspace/xcuserdata/gaofu.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /ScanCode.xcodeproj/xcuserdata/gaofu.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /ScanCode.xcodeproj/xcuserdata/gaofu.xcuserdatad/xcschemes/ScanCode.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /ScanCode.xcodeproj/xcuserdata/gaofu.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ScanCode.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | FD2762EF1EA8B4600066E7A8 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /ScanCode/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // ScanCode 4 | // 5 | // Created by gaofu on 2017/4/20. 6 | // Copyright © 2017年 gaofu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /ScanCode/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // ScanCode 4 | // 5 | // Created by gaofu on 2017/4/20. 6 | // Copyright © 2017年 gaofu. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // 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. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // 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. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // 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. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // 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. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /ScanCode/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /ScanCode/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 | 27 | 28 | -------------------------------------------------------------------------------- /ScanCode/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 | 30 | 31 | 32 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 108 | 120 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 219 | 225 | 226 | 227 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | -------------------------------------------------------------------------------- /ScanCode/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 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.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | NSCameraUsageDescription 24 | 25 | NSPhotoLibraryUsageDescription 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UIRequiredDeviceCapabilities 32 | 33 | armv7 34 | 35 | UISupportedInterfaceOrientations 36 | 37 | UIInterfaceOrientationPortrait 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /ScanCode/MyQRCodeViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MyQRCodeViewController.h 3 | // demo 4 | // 5 | // Created by gaofu on 2017/4/10. 6 | // Copyright © 2017年 siruijk. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface MyQRCodeViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ScanCode/MyQRCodeViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // MyQRCodeViewController.m 3 | // demo 4 | // 5 | // Created by gaofu on 2017/4/10. 6 | // Copyright © 2017年 siruijk. All rights reserved. 7 | // 8 | 9 | #import "MyQRCodeViewController.h" 10 | #import "NSString+QRCode.h" 11 | 12 | @interface MyQRCodeViewController () 13 | 14 | @end 15 | 16 | @implementation MyQRCodeViewController 17 | { 18 | __weak IBOutlet UIImageView *_headImageView; 19 | __weak IBOutlet UILabel *_nameLabel; 20 | __weak IBOutlet UILabel *_addressLabel; 21 | __weak IBOutlet UIImageView *_QRCodeImageView; 22 | } 23 | 24 | - (void)viewDidLoad 25 | { 26 | [super viewDidLoad]; 27 | // Do any additional setup after loading the view. 28 | 29 | dispatch_async(dispatch_get_global_queue(0, 0), ^{ 30 | UIImage *image = [@"大家好,我是炮炮兵!" generateQRCodeWithLogo:_headImageView.image]; 31 | dispatch_async(dispatch_get_main_queue(), ^{ 32 | _QRCodeImageView.image = image; 33 | }); 34 | }); 35 | 36 | } 37 | 38 | 39 | 40 | 41 | - (void)didReceiveMemoryWarning 42 | { 43 | [super didReceiveMemoryWarning]; 44 | // Dispose of any resources that can be recreated. 45 | } 46 | 47 | /* 48 | #pragma mark - Navigation 49 | 50 | // In a storyboard-based application, you will often want to do a little preparation before navigation 51 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 52 | // Get the new view controller using [segue destinationViewController]. 53 | // Pass the selected object to the new view controller. 54 | } 55 | */ 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /ScanCode/Pictures.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /ScanCode/Pictures.xcassets/headerimage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "headerimage@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "headerimage@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /ScanCode/Pictures.xcassets/headerimage.imageset/headerimage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fuaiyi/ScanCode/825857575bbd20da3d28dd1fd3e8fb983795d30e/ScanCode/Pictures.xcassets/headerimage.imageset/headerimage@2x.png -------------------------------------------------------------------------------- /ScanCode/Pictures.xcassets/headerimage.imageset/headerimage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fuaiyi/ScanCode/825857575bbd20da3d28dd1fd3e8fb983795d30e/ScanCode/Pictures.xcassets/headerimage.imageset/headerimage@3x.png -------------------------------------------------------------------------------- /ScanCode/Pictures.xcassets/scancode_box.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "scancode_box@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "scancode_box@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /ScanCode/Pictures.xcassets/scancode_box.imageset/scancode_box@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fuaiyi/ScanCode/825857575bbd20da3d28dd1fd3e8fb983795d30e/ScanCode/Pictures.xcassets/scancode_box.imageset/scancode_box@2x.png -------------------------------------------------------------------------------- /ScanCode/Pictures.xcassets/scancode_box.imageset/scancode_box@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fuaiyi/ScanCode/825857575bbd20da3d28dd1fd3e8fb983795d30e/ScanCode/Pictures.xcassets/scancode_box.imageset/scancode_box@3x.png -------------------------------------------------------------------------------- /ScanCode/Pictures.xcassets/scancode_light.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "scancode_light@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "scancode_light@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /ScanCode/Pictures.xcassets/scancode_light.imageset/scancode_light@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fuaiyi/ScanCode/825857575bbd20da3d28dd1fd3e8fb983795d30e/ScanCode/Pictures.xcassets/scancode_light.imageset/scancode_light@2x.png -------------------------------------------------------------------------------- /ScanCode/Pictures.xcassets/scancode_light.imageset/scancode_light@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fuaiyi/ScanCode/825857575bbd20da3d28dd1fd3e8fb983795d30e/ScanCode/Pictures.xcassets/scancode_light.imageset/scancode_light@3x.png -------------------------------------------------------------------------------- /ScanCode/Pictures.xcassets/scancode_light_select.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "scancode_light_select@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "scancode_light_select@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /ScanCode/Pictures.xcassets/scancode_light_select.imageset/scancode_light_select@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fuaiyi/ScanCode/825857575bbd20da3d28dd1fd3e8fb983795d30e/ScanCode/Pictures.xcassets/scancode_light_select.imageset/scancode_light_select@2x.png -------------------------------------------------------------------------------- /ScanCode/Pictures.xcassets/scancode_light_select.imageset/scancode_light_select@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fuaiyi/ScanCode/825857575bbd20da3d28dd1fd3e8fb983795d30e/ScanCode/Pictures.xcassets/scancode_light_select.imageset/scancode_light_select@3x.png -------------------------------------------------------------------------------- /ScanCode/Pictures.xcassets/scancode_line.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "scancode_line@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "scancode_line@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /ScanCode/Pictures.xcassets/scancode_line.imageset/scancode_line@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fuaiyi/ScanCode/825857575bbd20da3d28dd1fd3e8fb983795d30e/ScanCode/Pictures.xcassets/scancode_line.imageset/scancode_line@2x.png -------------------------------------------------------------------------------- /ScanCode/Pictures.xcassets/scancode_line.imageset/scancode_line@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fuaiyi/ScanCode/825857575bbd20da3d28dd1fd3e8fb983795d30e/ScanCode/Pictures.xcassets/scancode_line.imageset/scancode_line@3x.png -------------------------------------------------------------------------------- /ScanCode/Pictures.xcassets/scancode_myqrcode.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "scancode_myqrcode@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "scancode_myqrcode@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /ScanCode/Pictures.xcassets/scancode_myqrcode.imageset/scancode_myqrcode@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fuaiyi/ScanCode/825857575bbd20da3d28dd1fd3e8fb983795d30e/ScanCode/Pictures.xcassets/scancode_myqrcode.imageset/scancode_myqrcode@2x.png -------------------------------------------------------------------------------- /ScanCode/Pictures.xcassets/scancode_myqrcode.imageset/scancode_myqrcode@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fuaiyi/ScanCode/825857575bbd20da3d28dd1fd3e8fb983795d30e/ScanCode/Pictures.xcassets/scancode_myqrcode.imageset/scancode_myqrcode@3x.png -------------------------------------------------------------------------------- /ScanCode/Pictures.xcassets/scancode_photo.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "scancode_photo@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "scancode_photo@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /ScanCode/Pictures.xcassets/scancode_photo.imageset/scancode_photo@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fuaiyi/ScanCode/825857575bbd20da3d28dd1fd3e8fb983795d30e/ScanCode/Pictures.xcassets/scancode_photo.imageset/scancode_photo@2x.png -------------------------------------------------------------------------------- /ScanCode/Pictures.xcassets/scancode_photo.imageset/scancode_photo@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fuaiyi/ScanCode/825857575bbd20da3d28dd1fd3e8fb983795d30e/ScanCode/Pictures.xcassets/scancode_photo.imageset/scancode_photo@3x.png -------------------------------------------------------------------------------- /ScanCode/ScanCode/NSString+QRCode.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+QRCode.h 3 | // demo 4 | // 5 | // Created by gaofu on 2017/4/10. 6 | // Copyright © 2017年 siruijk. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSString (QRCode) 12 | /** 13 | 1.生成二维码 14 | 15 | - returns: 黑白普通二维码(大小为300) 16 | */ 17 | -(UIImage*)generateQRCode; 18 | 19 | 20 | 21 | /** 22 | 2.生成二维码 23 | 24 | - parameter size: 大小 25 | 26 | - returns: 生成带大小参数的黑白普通二维码 27 | */ 28 | -(UIImage*)generateQRCodeWithSize:(CGFloat)size; 29 | 30 | 31 | 32 | /** 33 | 3.生成二维码 34 | 35 | - parameter logo: 图标 36 | 37 | - returns: 生成带Logo二维码(大小:300) 38 | */ 39 | -(UIImage*)generateQRCodeWithLogo:(UIImage*)logo; 40 | 41 | 42 | 43 | /** 44 | 4.生成二维码 45 | 46 | - parameter size: 大小 47 | - parameter logo: 图标 48 | 49 | - returns: 生成大小和Logo的二维码 50 | */ 51 | -(UIImage*)generateQRCodeWithSize:(CGFloat)size 52 | logo:(UIImage*)logo; 53 | 54 | 55 | 56 | /** 57 | 5.生成二维码 58 | 59 | - parameter size: 大小 60 | - parameter color: 颜色 61 | - parameter bgColor: 背景颜色 62 | - parameter logo: 图标 63 | 64 | - returns: 带Logo、颜色二维码 65 | */ 66 | -(UIImage*)generateQRCodeWithSize:(CGFloat)size 67 | color:(UIColor*)color 68 | bgColor:(UIColor*)bgColor 69 | logo:(UIImage*)logo; 70 | 71 | 72 | 73 | /** 74 | 6.生成二维码 75 | 76 | - parameter size: 大小 77 | - parameter color: 颜色 78 | - parameter bgColor: 背景颜色 79 | - parameter logo: 图标 80 | - parameter radius: 圆角 81 | - parameter borderLineWidth: 线宽 82 | - parameter borderLineColor: 线颜色 83 | - parameter boderWidth: 带宽 84 | - parameter borderColor: 带颜色 85 | 86 | - returns: 自定义二维码 87 | */ 88 | -(UIImage*)generateQRCodeWithSize:(CGFloat)size 89 | color:(UIColor*)color 90 | bgColor:(UIColor*)bgColor 91 | logo:(UIImage*)logo 92 | radius:(CGFloat)radius 93 | borderLineWidth:(CGFloat)borderLineWidth 94 | borderLineColor:(UIColor*)borderLineColor 95 | boderWidth:(CGFloat)boderWidth 96 | borderColor:(UIColor*)borderColor; 97 | 98 | 99 | 100 | 101 | 102 | @end 103 | -------------------------------------------------------------------------------- /ScanCode/ScanCode/NSString+QRCode.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+QRCode.m 3 | // demo 4 | // 5 | // Created by gaofu on 2017/4/10. 6 | // Copyright © 2017年 siruijk. All rights reserved. 7 | // 8 | 9 | #import "NSString+QRCode.h" 10 | #import "UIImage+Extend.h" 11 | 12 | @implementation NSString (QRCode) 13 | 14 | 15 | /** 16 | 1.生成二维码 17 | 18 | - returns: 黑白普通二维码(大小为300) 19 | */ 20 | -(UIImage*)generateQRCode 21 | { 22 | return [self generateQRCodeWithSize:0.f]; 23 | } 24 | 25 | 26 | /** 27 | 2.生成二维码 28 | 29 | - parameter size: 大小 30 | 31 | - returns: 生成带大小参数的黑白普通二维码 32 | */ 33 | -(UIImage*)generateQRCodeWithSize:(CGFloat)size 34 | { 35 | return [self generateQRCodeWithSize:size logo:nil]; 36 | } 37 | 38 | 39 | /** 40 | 3.生成二维码 41 | 42 | - parameter logo: 图标 43 | 44 | - returns: 生成带Logo二维码(大小:300) 45 | */ 46 | -(UIImage*)generateQRCodeWithLogo:(UIImage*)logo 47 | { 48 | return [self generateQRCodeWithSize:0 logo:logo]; 49 | } 50 | 51 | 52 | /** 53 | 4.生成二维码 54 | 55 | - parameter size: 大小 56 | - parameter logo: 图标 57 | 58 | - returns: 生成大小和Logo的二维码 59 | */ 60 | -(UIImage*)generateQRCodeWithSize:(CGFloat)size 61 | logo:(UIImage*)logo 62 | { 63 | UIColor* color = [UIColor blackColor];//二维码颜色 64 | UIColor* bgColor = [UIColor whiteColor];//二维码背景颜色 65 | 66 | return [self generateQRCodeWithSize:size color:color bgColor:bgColor logo:logo]; 67 | } 68 | 69 | 70 | /** 71 | 5.生成二维码 72 | 73 | - parameter size: 大小 74 | - parameter color: 颜色 75 | - parameter bgColor: 背景颜色 76 | - parameter logo: 图标 77 | 78 | - returns: 带Logo、颜色二维码 79 | */ 80 | -(UIImage*)generateQRCodeWithSize:(CGFloat)size 81 | color:(UIColor*)color 82 | bgColor:(UIColor*)bgColor 83 | logo:(UIImage*)logo 84 | { 85 | CGFloat radius = 5.0f;//圆角 86 | CGFloat borderLineWidth = 1.5f;//线宽 87 | UIColor* borderLineColor = [UIColor grayColor];//线颜色 88 | CGFloat boderWidth = 8.0f;//白带宽度 89 | UIColor* borderColor = [UIColor whiteColor];//白带颜色 90 | 91 | return [self generateQRCodeWithSize:size color:color bgColor:bgColor logo:logo radius:radius borderLineWidth:borderLineWidth borderLineColor:borderLineColor boderWidth:boderWidth borderColor:borderColor]; 92 | } 93 | 94 | 95 | /** 96 | 6.生成二维码 97 | 98 | - parameter size: 大小 99 | - parameter color: 颜色 100 | - parameter bgColor: 背景颜色 101 | - parameter logo: 图标 102 | - parameter radius: 圆角 103 | - parameter borderLineWidth: 线宽 104 | - parameter borderLineColor: 线颜色 105 | - parameter boderWidth: 带宽 106 | - parameter borderColor: 带颜色 107 | 108 | - returns: 自定义二维码 109 | */ 110 | -(UIImage*)generateQRCodeWithSize:(CGFloat)size 111 | color:(UIColor*)color 112 | bgColor:(UIColor*)bgColor 113 | logo:(UIImage*)logo 114 | radius:(CGFloat)radius 115 | borderLineWidth:(CGFloat)borderLineWidth 116 | borderLineColor:(UIColor*)borderLineColor 117 | boderWidth:(CGFloat)boderWidth 118 | borderColor:(UIColor*)borderColor 119 | { 120 | CIImage* ciImage = [self generateCIImageWithSize:size color:color bgColor:bgColor]; 121 | UIImage *image = [UIImage imageWithCIImage:ciImage]; 122 | if (!logo) return image; 123 | if (!image) return nil; 124 | 125 | CGFloat logoWidth = image.size.width/4; 126 | CGRect logoFrame = CGRectMake((image.size.width - logoWidth) / 2,(image.size.width - logoWidth) / 2,logoWidth,logoWidth); 127 | 128 | // 绘制logo 129 | UIGraphicsBeginImageContextWithOptions(image.size, false, [UIScreen mainScreen].scale); 130 | [image drawInRect:CGRectMake(0, 0, image.size.width, image.size.height)]; 131 | 132 | //线框 133 | UIImage*logoBorderLineImagae = [logo getRoundRectImageWithSize:logoWidth radius:radius borderWidth:borderLineWidth borderColor:borderLineColor]; 134 | //边框 135 | UIImage*logoBorderImagae = [logoBorderLineImagae getRoundRectImageWithSize:logoWidth radius:radius borderWidth:boderWidth borderColor:borderColor]; 136 | 137 | [logoBorderImagae drawInRect:logoFrame]; 138 | 139 | UIImage* QRCodeImage = UIGraphicsGetImageFromCurrentImageContext(); 140 | UIGraphicsEndImageContext(); 141 | 142 | return QRCodeImage; 143 | } 144 | 145 | 146 | /** 147 | 7.生成CIImage 148 | 149 | - parameter size: 大小 150 | - parameter color: 颜色 151 | - parameter bgColor: 背景颜色 152 | 153 | - returns: CIImage 154 | */ 155 | -(CIImage*)generateCIImageWithSize:(CGFloat)size color:(UIColor*)color bgColor:(UIColor*)bgColor 156 | { 157 | //设置缺省值 158 | CGFloat QRCodeSize = 300;//默认300 159 | UIColor* QRCodeColor = [UIColor blackColor];//默认黑色二维码 160 | UIColor * QRCodeBgColor = [UIColor whiteColor];//默认白色背景 161 | 162 | //2.二维码滤镜 163 | NSData* contentData = [self dataUsingEncoding:NSUTF8StringEncoding]; 164 | CIFilter *fileter = [CIFilter filterWithName:@"CIQRCodeGenerator"]; 165 | [fileter setValue:contentData forKey:@"inputMessage"]; 166 | [fileter setValue:@"H" forKey:@"inputCorrectionLevel"]; 167 | CIImage *ciImage = fileter.outputImage; 168 | 169 | //3.颜色滤镜 170 | CIFilter *colorFilter = [CIFilter filterWithName:@"CIFalseColor"]; 171 | [colorFilter setValue:ciImage forKey:@"inputImage"]; 172 | [colorFilter setValue:[CIColor colorWithCGColor:QRCodeColor.CGColor] forKey:@"inputColor0"];// 二维码颜色 173 | [colorFilter setValue:[CIColor colorWithCGColor:QRCodeBgColor.CGColor] forKey:@"inputColor1"];// 背景色 174 | 175 | 176 | //4.生成处理 177 | CIImage*outImage = colorFilter.outputImage; 178 | CGFloat scale = QRCodeSize / outImage.extent.size.width; 179 | 180 | return [colorFilter.outputImage imageByApplyingTransform:CGAffineTransformMakeScale(scale, scale)]; 181 | } 182 | 183 | 184 | @end 185 | -------------------------------------------------------------------------------- /ScanCode/ScanCode/UIImage+Extend.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+Extend.h 3 | // demo 4 | // 5 | // Created by gaofu on 2017/3/10. 6 | // Copyright © 2017年 siruijk. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIImage (Extend) 12 | 13 | /** 14 | 生成圆角图片 15 | 16 | @param size 大小 17 | @param radius 圆角 18 | @param borderWidth 线宽 19 | @param borderColor 线颜色 20 | @return 图片 21 | */ 22 | -(UIImage*)getRoundRectImageWithSize:(CGFloat)size radius:(CGFloat)radius borderWidth:(CGFloat)borderWidth borderColor:(UIColor*)borderColor; 23 | -(UIImage*)getRoundRectImageWithSize:(CGFloat)size radius:(CGFloat)radius; 24 | 25 | 26 | /** 27 | 识别图片二维码 28 | 29 | @return 二维码内容 30 | */ 31 | -(NSString*)scanCodeContent; 32 | @end 33 | -------------------------------------------------------------------------------- /ScanCode/ScanCode/UIImage+Extend.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+Extend.m 3 | // demo 4 | // 5 | // Created by gaofu on 2017/3/10. 6 | // Copyright © 2017年 siruijk. All rights reserved. 7 | // 8 | 9 | #import "UIImage+Extend.h" 10 | 11 | @implementation UIImage (Extend) 12 | 13 | 14 | -(UIImage*)getRoundRectImageWithSize:(CGFloat)size radius:(CGFloat)radius 15 | { 16 | return [self getRoundRectImageWithSize:size radius:radius borderWidth:0 borderColor:nil]; 17 | } 18 | 19 | -(UIImage*)getRoundRectImageWithSize:(CGFloat)size radius:(CGFloat)radius borderWidth:(CGFloat)borderWidth borderColor:(UIColor*)borderColor 20 | { 21 | 22 | CGFloat scale = 1.0f * self.size.width / size ; 23 | 24 | //初始值 25 | CGFloat defaultBorderWidth = borderWidth * scale; 26 | UIColor* defaultBorderColor = borderColor ? borderColor : [UIColor clearColor]; 27 | 28 | radius = radius * scale; 29 | CGRect react = CGRectMake(defaultBorderWidth,defaultBorderWidth,self.size.width - 2 * defaultBorderWidth,self.size.height - 2 * defaultBorderWidth); 30 | 31 | //绘制图片设置 32 | UIGraphicsBeginImageContextWithOptions(self.size, false, [UIScreen mainScreen].scale); 33 | UIBezierPath* path = [UIBezierPath bezierPathWithRoundedRect:react cornerRadius:radius]; 34 | 35 | //绘制边框 36 | path.lineWidth = defaultBorderWidth; 37 | [defaultBorderColor setStroke]; 38 | [path stroke]; 39 | [path addClip]; 40 | 41 | //画图片 42 | [self drawInRect:react]; 43 | UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext(); 44 | UIGraphicsEndImageContext(); 45 | 46 | return newImage; 47 | 48 | } 49 | 50 | 51 | -(NSString*)scanCodeContent 52 | { 53 | NSData *imageData = UIImagePNGRepresentation(self); 54 | CIImage *ciImage = [CIImage imageWithData:imageData]; 55 | 56 | CIContext *context = [CIContext contextWithOptions:@{kCIContextUseSoftwareRenderer : @(false), kCIContextPriorityRequestLow : @(false)}]; 57 | //创建探测器 58 | CIDetector *detector = [CIDetector detectorOfType:CIDetectorTypeQRCode context:context options:@{CIDetectorAccuracy: CIDetectorAccuracyHigh}]; 59 | NSArray *features = [detector featuresInImage:ciImage]; 60 | CIQRCodeFeature *feature = [features firstObject]; 61 | 62 | return feature.messageString.length ? feature.messageString : @"未识别!"; 63 | } 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /ScanCode/ScanCodeViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ScanCodeViewController.h 3 | // demo 4 | // 5 | // Created by gaofu on 2017/4/10. 6 | // Copyright © 2017年 siruijk. All rights reserved. 7 | // 8 | 9 | 10 | #import 11 | 12 | @interface ScanCodeViewController : UIViewController 13 | 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /ScanCode/ScanCodeViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ScanCodeViewController.m 3 | // demo 4 | // 5 | // Created by gaofu on 2017/4/10. 6 | // Copyright © 2017年 siruijk. All rights reserved. 7 | // 8 | 9 | #import "ScanCodeViewController.h" 10 | #import 11 | #import "UIImage+Extend.h" 12 | 13 | const static CGFloat animationTime = 2.5f;//扫描时长 14 | 15 | @interface ScanCodeViewController () 16 | 17 | @property (nonatomic,strong) AVCaptureSession *captureSession; 18 | @property (nonatomic,strong) AVCaptureVideoPreviewLayer *captureVideoPreviewLayer; 19 | @property (nonatomic,strong) AVCaptureMetadataOutput *captureMetadataOutput; 20 | @property (nonatomic,strong) CAShapeLayer *scanPaneBgLayer; 21 | 22 | @end 23 | 24 | @implementation ScanCodeViewController 25 | { 26 | __weak IBOutlet UIImageView *_scanPane;//扫描框 27 | __weak IBOutlet UILabel *_contentLabel; 28 | __weak IBOutlet NSLayoutConstraint *_boxLayoutConstraint; 29 | __weak IBOutlet UIActivityIndicatorView *_loaddingIndicatorView; 30 | UIImageView *_scanLine;//扫描线 31 | } 32 | 33 | 34 | #pragma mark - 35 | #pragma mark Lifecycle 36 | 37 | - (void)viewDidLoad 38 | { 39 | [super viewDidLoad]; 40 | 41 | [self initScanCode]; 42 | [self initScanLine]; 43 | } 44 | 45 | 46 | -(void)viewDidAppear:(BOOL)animated 47 | { 48 | [super viewDidAppear:animated]; 49 | 50 | [self startScan]; 51 | } 52 | 53 | -(CAShapeLayer *)scanPaneBgLayer 54 | { 55 | 56 | if (!_scanPaneBgLayer) 57 | { 58 | _scanPaneBgLayer = [CAShapeLayer layer]; 59 | } 60 | return _scanPaneBgLayer; 61 | } 62 | 63 | #pragma mark - 64 | #pragma mark Interface Components 65 | 66 | //扫描线 67 | -(void)initScanLine 68 | { 69 | 70 | _scanLine = [UIImageView new]; 71 | _scanLine.image = [UIImage imageNamed:@"scancode_line"]; 72 | [_scanPane addSubview:_scanLine]; 73 | 74 | [self setScanReact:YES]; 75 | [self.view.layer insertSublayer:self.scanPaneBgLayer above:self.captureVideoPreviewLayer]; 76 | } 77 | 78 | //绘制扫描框背景 79 | - (void)setScanReact:(BOOL)loading 80 | { 81 | 82 | CGRect scanRect = _scanPane.frame; 83 | 84 | UIBezierPath *path = [UIBezierPath bezierPathWithRect:scanRect]; 85 | [path appendPath:[UIBezierPath bezierPathWithRect:self.view.bounds]]; 86 | 87 | [self.scanPaneBgLayer setFillRule:kCAFillRuleEvenOdd]; 88 | [self.scanPaneBgLayer setPath:path.CGPath]; 89 | [self.scanPaneBgLayer setFillColor:[UIColor colorWithWhite:0 alpha:loading ? 1 : 0.6].CGColor]; 90 | } 91 | 92 | 93 | #pragma mark - 94 | #pragma mark Target Action Methods 95 | 96 | //开灯按钮 97 | - (IBAction)lightBtnAction:(UIButton *)sender 98 | { 99 | sender.selected = !sender.selected; 100 | [self turnTorchOn:sender.selected]; 101 | } 102 | 103 | //打开相册 104 | - (IBAction)photoBtnAction:(UIButton *)sender 105 | { 106 | UIImagePickerController *picker = [[UIImagePickerController alloc] init]; 107 | picker.delegate = self; 108 | picker.allowsEditing = true; 109 | [self presentViewController:picker animated:true completion:nil]; 110 | } 111 | 112 | #pragma mark - 113 | #pragma mark DataRequest 114 | 115 | 116 | #pragma mark - 117 | #pragma mark Private Methods 118 | 119 | //初始化扫描二维码 120 | -(void)initScanCode 121 | { 122 | 123 | AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; 124 | NSError *error = nil; 125 | AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device error:&error]; 126 | 127 | if (error) 128 | { 129 | [self showMessage:@"摄像头不可用" title:@"温馨提示" andler:nil]; 130 | return; 131 | } 132 | 133 | if ([device lockForConfiguration:nil]) 134 | { 135 | //自动白平衡 136 | if ([device isWhiteBalanceModeSupported:AVCaptureWhiteBalanceModeContinuousAutoWhiteBalance]) 137 | { 138 | [device setWhiteBalanceMode:AVCaptureWhiteBalanceModeContinuousAutoWhiteBalance]; 139 | } 140 | //自动对焦 141 | if ([device isFocusModeSupported:AVCaptureFocusModeContinuousAutoFocus]) 142 | { 143 | [device setFocusMode:AVCaptureFocusModeContinuousAutoFocus]; 144 | } 145 | //自动曝光 146 | if ([device isExposureModeSupported:AVCaptureExposureModeContinuousAutoExposure]) 147 | { 148 | [device setExposureMode:AVCaptureExposureModeContinuousAutoExposure]; 149 | } 150 | [device unlockForConfiguration]; 151 | } 152 | self.captureMetadataOutput = [[AVCaptureMetadataOutput alloc] init]; 153 | [self.captureMetadataOutput setMetadataObjectsDelegate:self queue:dispatch_get_main_queue()]; 154 | self.captureSession = [[AVCaptureSession alloc] init]; 155 | [self.captureSession setSessionPreset:AVCaptureSessionPresetHigh]; 156 | [self.self.captureSession canAddInput:input] ? [self.captureSession addInput:input] : nil; 157 | [self.captureSession canAddOutput:self.captureMetadataOutput] ? [self.captureSession addOutput:self.captureMetadataOutput] : nil; 158 | 159 | [self.captureMetadataOutput setMetadataObjectTypes:@[ 160 | AVMetadataObjectTypeQRCode, 161 | AVMetadataObjectTypeCode39Code, 162 | AVMetadataObjectTypeCode128Code, 163 | AVMetadataObjectTypeCode39Mod43Code, 164 | AVMetadataObjectTypeEAN13Code, 165 | AVMetadataObjectTypeEAN8Code, 166 | AVMetadataObjectTypeCode93Code 167 | ]]; 168 | 169 | self.captureVideoPreviewLayer = [AVCaptureVideoPreviewLayer layerWithSession:self.captureSession]; 170 | self.captureVideoPreviewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill; 171 | self.captureVideoPreviewLayer.frame = self.view.layer.bounds; 172 | [self.view.layer insertSublayer:self.captureVideoPreviewLayer atIndex:0]; 173 | 174 | [self loadScan]; 175 | } 176 | 177 | //启动扫描 178 | -(void)loadScan 179 | { 180 | [_loaddingIndicatorView startAnimating ]; 181 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ 182 | [self.captureSession startRunning]; 183 | dispatch_async(dispatch_get_main_queue(), ^{ 184 | [_loaddingIndicatorView stopAnimating]; 185 | [UIView animateWithDuration:0.25 animations:^{ 186 | _contentLabel.alpha = 1; 187 | _boxLayoutConstraint.constant = [UIScreen mainScreen].bounds.size.width*0.6; 188 | [self.view layoutIfNeeded]; 189 | } completion:^(BOOL finished) { 190 | _scanLine.frame = CGRectMake(0 , 0, [UIScreen mainScreen].bounds.size.width*0.6, 3); 191 | [_scanLine.layer addAnimation:[self moveAnimation] forKey:nil]; 192 | [self setScanReact:NO]; 193 | }]; 194 | self.captureMetadataOutput.rectOfInterest = [self.captureVideoPreviewLayer metadataOutputRectOfInterestForRect:_scanPane.frame]; 195 | }); 196 | }); 197 | } 198 | 199 | //开始扫描 200 | - (void)startScan 201 | { 202 | [_scanLine.layer addAnimation:[self moveAnimation] forKey:nil]; 203 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ 204 | [self.captureSession startRunning]; 205 | }); 206 | } 207 | 208 | //停止扫描 209 | - (void)stopScan 210 | { 211 | 212 | [_scanLine.layer removeAllAnimations]; 213 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ 214 | if (self.captureSession.isRunning ) 215 | { 216 | [self.captureSession stopRunning]; 217 | } 218 | }); 219 | } 220 | 221 | //扫描动画 222 | -(CABasicAnimation*)moveAnimation 223 | { 224 | CGPoint starPoint = CGPointMake(_scanLine .center.x , 1); 225 | CGPoint endPoint = CGPointMake(_scanLine.center.x, _scanPane.bounds.size.height - 2); 226 | 227 | CABasicAnimation*translation = [CABasicAnimation animationWithKeyPath:@"position"]; 228 | translation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; 229 | 230 | translation.fromValue = [NSValue valueWithCGPoint:starPoint]; 231 | translation.toValue = [NSValue valueWithCGPoint:endPoint]; 232 | translation.duration = animationTime; 233 | translation.repeatCount = CGFLOAT_MAX; 234 | translation.autoreverses = YES; 235 | 236 | return translation; 237 | } 238 | 239 | //散光灯 240 | - (void)turnTorchOn: (BOOL)on 241 | { 242 | Class captureDeviceClass = NSClassFromString(@"AVCaptureDevice"); 243 | 244 | if (captureDeviceClass != nil) 245 | { 246 | AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; 247 | 248 | if ([device hasTorch] && [device hasFlash]) 249 | { 250 | [device lockForConfiguration:nil]; 251 | if (on && device.torchMode == AVCaptureTorchModeOff) 252 | { 253 | [device setTorchMode:AVCaptureTorchModeOn]; 254 | [device setFlashMode:AVCaptureFlashModeOn]; 255 | } 256 | if (!on && device.torchMode == AVCaptureTorchModeOn) 257 | { 258 | [device setTorchMode:AVCaptureTorchModeOff]; 259 | [device setFlashMode:AVCaptureFlashModeOff]; 260 | } 261 | [device unlockForConfiguration]; 262 | } 263 | } 264 | } 265 | 266 | //扫描结果处理 267 | -(void)dealwithResult:(NSString*)result 268 | { 269 | [self playScanCodeSound]; 270 | [self showMessage:result title:@"扫描结果" andler:^(UIAlertAction *action) { 271 | [self startScan]; 272 | }]; 273 | } 274 | 275 | //播放提示音 276 | - (void)playScanCodeSound 277 | { 278 | NSString *path = [[NSBundle mainBundle] pathForResource:@"scancode.caf" ofType:nil]; 279 | 280 | SystemSoundID soundID = 0; 281 | AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath:path],&soundID); 282 | AudioServicesPlayAlertSound(soundID); 283 | } 284 | 285 | -(void)showMessage:(NSString*)message title:(NSString*)title andler:(void (^)(UIAlertAction *action))handler 286 | { 287 | UIAlertController *alert = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert]; 288 | UIAlertAction *action = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:handler]; 289 | [alert addAction:action]; 290 | [self presentViewController:alert animated:YES completion:nil]; 291 | 292 | } 293 | 294 | 295 | #pragma mark - 296 | #pragma mark AVCaptureMetadataOutputObjects Delegate 297 | 298 | -(void)captureOutput:(AVCaptureOutput *)captureOutput didOutputMetadataObjects:(NSArray *)metadataObjects fromConnection:(AVCaptureConnection *)connection 299 | { 300 | [self stopScan]; 301 | 302 | //扫完完成 303 | if (metadataObjects.count > 0) 304 | { 305 | AVMetadataMachineReadableCodeObject *obj = metadataObjects[0]; 306 | NSString *result = obj.stringValue; 307 | [self dealwithResult:result]; 308 | } 309 | } 310 | 311 | 312 | #pragma mark - 313 | #pragma mark UIImagePicker Delegate 314 | 315 | - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info 316 | { 317 | UIImage *image = info[UIImagePickerControllerEditedImage]; 318 | if (!image) 319 | { 320 | image = info[UIImagePickerControllerOriginalImage]; 321 | } 322 | [_loaddingIndicatorView startAnimating]; 323 | 324 | [picker dismissViewControllerAnimated:YES completion:^{ 325 | 326 | NSString *scanResult = [image scanCodeContent]; 327 | 328 | [_loaddingIndicatorView stopAnimating]; 329 | 330 | [self dealwithResult:scanResult]; 331 | 332 | }]; 333 | } 334 | 335 | - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker 336 | { 337 | [picker dismissViewControllerAnimated:true completion:nil]; 338 | } 339 | 340 | 341 | #pragma mark - 342 | #pragma mark Dealloc 343 | 344 | -(void)dealloc 345 | { 346 | [self.captureSession stopRunning]; 347 | _captureMetadataOutput = nil; 348 | _captureSession = nil; 349 | [_captureVideoPreviewLayer removeFromSuperlayer]; 350 | _captureVideoPreviewLayer = nil; 351 | } 352 | 353 | @end 354 | -------------------------------------------------------------------------------- /ScanCode/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // ScanCode 4 | // 5 | // Created by gaofu on 2017/4/20. 6 | // Copyright © 2017年 gaofu. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ScanCode/scancode.caf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fuaiyi/ScanCode/825857575bbd20da3d28dd1fd3e8fb983795d30e/ScanCode/scancode.caf -------------------------------------------------------------------------------- /ScanCode/zh-Hans.lproj/LaunchScreen.strings: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /ScanCode/zh-Hans.lproj/Main.strings: -------------------------------------------------------------------------------- 1 | 2 | /* Class = "UILabel"; text = "泡泡兵"; ObjectID = "36m-NK-FDX"; */ 3 | "36m-NK-FDX.text" = "泡泡兵"; 4 | 5 | /* Class = "UILabel"; text = "将二维码/条形码放入框内,即可自动扫描"; ObjectID = "3vK-YD-pY5"; */ 6 | "3vK-YD-pY5.text" = "将二维码/条形码放入框内,即可自动扫描"; 7 | 8 | /* Class = "UILabel"; text = "广东 深圳"; ObjectID = "8Fd-Ca-ezU"; */ 9 | "8Fd-Ca-ezU.text" = "广东 深圳"; 10 | 11 | /* Class = "UILabel"; text = "扫一扫上面的二维码图案,加我好友哟"; ObjectID = "Nqk-DO-fs2"; */ 12 | "Nqk-DO-fs2.text" = "扫一扫上面的二维码图案,加我好友哟"; 13 | 14 | /* Class = "UILabel"; text = "扫一扫"; ObjectID = "R0W-yj-if3"; */ 15 | "R0W-yj-if3.text" = "扫一扫"; 16 | 17 | /* Class = "UIViewController"; title = "我的二维码"; ObjectID = "XZI-qw-GJ2"; */ 18 | "XZI-qw-GJ2.title" = "我的二维码"; 19 | 20 | /* Class = "UILabel"; text = "我的二维码"; ObjectID = "aRD-B7-nv9"; */ 21 | "aRD-B7-nv9.text" = "我的二维码"; 22 | 23 | /* Class = "UIViewController"; title = "扫一扫"; ObjectID = "dfD-vp-eSt"; */ 24 | "dfD-vp-eSt.title" = "扫一扫"; 25 | 26 | /* Class = "UINavigationItem"; title = "二维码"; ObjectID = "mmP-XV-afW"; */ 27 | "mmP-XV-afW.title" = "二维码"; 28 | --------------------------------------------------------------------------------