├── .gitignore ├── KDQRCodeShow.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── kingiol.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── kingiol.xcuserdatad │ └── xcschemes │ ├── KDQRCodeShow.xcscheme │ └── xcschememanagement.plist ├── KDQRCodeShow ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── QRCodeViewController.swift └── ViewController.swift ├── LICENSE ├── README.md └── screenshot └── screenshot.jpg /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | # Pods/ 27 | 28 | # Carthage 29 | # 30 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 31 | # Carthage/Checkouts 32 | 33 | Carthage/Build 34 | -------------------------------------------------------------------------------- /KDQRCodeShow.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 629559801C01AA6D0004453C /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6295597F1C01AA6D0004453C /* AppDelegate.swift */; }; 11 | 629559821C01AA6D0004453C /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 629559811C01AA6D0004453C /* ViewController.swift */; }; 12 | 629559851C01AA6D0004453C /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 629559831C01AA6D0004453C /* Main.storyboard */; }; 13 | 629559871C01AA6D0004453C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 629559861C01AA6D0004453C /* Assets.xcassets */; }; 14 | 6295598A1C01AA6D0004453C /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 629559881C01AA6D0004453C /* LaunchScreen.storyboard */; }; 15 | 629559921C01AB960004453C /* QRCodeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 629559911C01AB960004453C /* QRCodeViewController.swift */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXFileReference section */ 19 | 6295597C1C01AA6D0004453C /* KDQRCodeShow.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = KDQRCodeShow.app; sourceTree = BUILT_PRODUCTS_DIR; }; 20 | 6295597F1C01AA6D0004453C /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 21 | 629559811C01AA6D0004453C /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 22 | 629559841C01AA6D0004453C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 23 | 629559861C01AA6D0004453C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 24 | 629559891C01AA6D0004453C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 25 | 6295598B1C01AA6D0004453C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 26 | 629559911C01AB960004453C /* QRCodeViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QRCodeViewController.swift; sourceTree = ""; }; 27 | /* End PBXFileReference section */ 28 | 29 | /* Begin PBXFrameworksBuildPhase section */ 30 | 629559791C01AA6D0004453C /* Frameworks */ = { 31 | isa = PBXFrameworksBuildPhase; 32 | buildActionMask = 2147483647; 33 | files = ( 34 | ); 35 | runOnlyForDeploymentPostprocessing = 0; 36 | }; 37 | /* End PBXFrameworksBuildPhase section */ 38 | 39 | /* Begin PBXGroup section */ 40 | 629559731C01AA6D0004453C = { 41 | isa = PBXGroup; 42 | children = ( 43 | 6295597E1C01AA6D0004453C /* KDQRCodeShow */, 44 | 6295597D1C01AA6D0004453C /* Products */, 45 | ); 46 | sourceTree = ""; 47 | }; 48 | 6295597D1C01AA6D0004453C /* Products */ = { 49 | isa = PBXGroup; 50 | children = ( 51 | 6295597C1C01AA6D0004453C /* KDQRCodeShow.app */, 52 | ); 53 | name = Products; 54 | sourceTree = ""; 55 | }; 56 | 6295597E1C01AA6D0004453C /* KDQRCodeShow */ = { 57 | isa = PBXGroup; 58 | children = ( 59 | 6295597F1C01AA6D0004453C /* AppDelegate.swift */, 60 | 629559811C01AA6D0004453C /* ViewController.swift */, 61 | 629559911C01AB960004453C /* QRCodeViewController.swift */, 62 | 629559831C01AA6D0004453C /* Main.storyboard */, 63 | 629559861C01AA6D0004453C /* Assets.xcassets */, 64 | 629559881C01AA6D0004453C /* LaunchScreen.storyboard */, 65 | 6295598B1C01AA6D0004453C /* Info.plist */, 66 | ); 67 | path = KDQRCodeShow; 68 | sourceTree = ""; 69 | }; 70 | /* End PBXGroup section */ 71 | 72 | /* Begin PBXNativeTarget section */ 73 | 6295597B1C01AA6D0004453C /* KDQRCodeShow */ = { 74 | isa = PBXNativeTarget; 75 | buildConfigurationList = 6295598E1C01AA6D0004453C /* Build configuration list for PBXNativeTarget "KDQRCodeShow" */; 76 | buildPhases = ( 77 | 629559781C01AA6D0004453C /* Sources */, 78 | 629559791C01AA6D0004453C /* Frameworks */, 79 | 6295597A1C01AA6D0004453C /* Resources */, 80 | ); 81 | buildRules = ( 82 | ); 83 | dependencies = ( 84 | ); 85 | name = KDQRCodeShow; 86 | productName = KDQRCodeShow; 87 | productReference = 6295597C1C01AA6D0004453C /* KDQRCodeShow.app */; 88 | productType = "com.apple.product-type.application"; 89 | }; 90 | /* End PBXNativeTarget section */ 91 | 92 | /* Begin PBXProject section */ 93 | 629559741C01AA6D0004453C /* Project object */ = { 94 | isa = PBXProject; 95 | attributes = { 96 | LastSwiftUpdateCheck = 0710; 97 | LastUpgradeCheck = 0710; 98 | ORGANIZATIONNAME = Kingiol; 99 | TargetAttributes = { 100 | 6295597B1C01AA6D0004453C = { 101 | CreatedOnToolsVersion = 7.1.1; 102 | }; 103 | }; 104 | }; 105 | buildConfigurationList = 629559771C01AA6D0004453C /* Build configuration list for PBXProject "KDQRCodeShow" */; 106 | compatibilityVersion = "Xcode 3.2"; 107 | developmentRegion = English; 108 | hasScannedForEncodings = 0; 109 | knownRegions = ( 110 | en, 111 | Base, 112 | ); 113 | mainGroup = 629559731C01AA6D0004453C; 114 | productRefGroup = 6295597D1C01AA6D0004453C /* Products */; 115 | projectDirPath = ""; 116 | projectRoot = ""; 117 | targets = ( 118 | 6295597B1C01AA6D0004453C /* KDQRCodeShow */, 119 | ); 120 | }; 121 | /* End PBXProject section */ 122 | 123 | /* Begin PBXResourcesBuildPhase section */ 124 | 6295597A1C01AA6D0004453C /* Resources */ = { 125 | isa = PBXResourcesBuildPhase; 126 | buildActionMask = 2147483647; 127 | files = ( 128 | 6295598A1C01AA6D0004453C /* LaunchScreen.storyboard in Resources */, 129 | 629559871C01AA6D0004453C /* Assets.xcassets in Resources */, 130 | 629559851C01AA6D0004453C /* Main.storyboard in Resources */, 131 | ); 132 | runOnlyForDeploymentPostprocessing = 0; 133 | }; 134 | /* End PBXResourcesBuildPhase section */ 135 | 136 | /* Begin PBXSourcesBuildPhase section */ 137 | 629559781C01AA6D0004453C /* Sources */ = { 138 | isa = PBXSourcesBuildPhase; 139 | buildActionMask = 2147483647; 140 | files = ( 141 | 629559921C01AB960004453C /* QRCodeViewController.swift in Sources */, 142 | 629559821C01AA6D0004453C /* ViewController.swift in Sources */, 143 | 629559801C01AA6D0004453C /* AppDelegate.swift in Sources */, 144 | ); 145 | runOnlyForDeploymentPostprocessing = 0; 146 | }; 147 | /* End PBXSourcesBuildPhase section */ 148 | 149 | /* Begin PBXVariantGroup section */ 150 | 629559831C01AA6D0004453C /* Main.storyboard */ = { 151 | isa = PBXVariantGroup; 152 | children = ( 153 | 629559841C01AA6D0004453C /* Base */, 154 | ); 155 | name = Main.storyboard; 156 | sourceTree = ""; 157 | }; 158 | 629559881C01AA6D0004453C /* LaunchScreen.storyboard */ = { 159 | isa = PBXVariantGroup; 160 | children = ( 161 | 629559891C01AA6D0004453C /* Base */, 162 | ); 163 | name = LaunchScreen.storyboard; 164 | sourceTree = ""; 165 | }; 166 | /* End PBXVariantGroup section */ 167 | 168 | /* Begin XCBuildConfiguration section */ 169 | 6295598C1C01AA6D0004453C /* Debug */ = { 170 | isa = XCBuildConfiguration; 171 | buildSettings = { 172 | ALWAYS_SEARCH_USER_PATHS = NO; 173 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 174 | CLANG_CXX_LIBRARY = "libc++"; 175 | CLANG_ENABLE_MODULES = YES; 176 | CLANG_ENABLE_OBJC_ARC = YES; 177 | CLANG_WARN_BOOL_CONVERSION = YES; 178 | CLANG_WARN_CONSTANT_CONVERSION = YES; 179 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 180 | CLANG_WARN_EMPTY_BODY = YES; 181 | CLANG_WARN_ENUM_CONVERSION = YES; 182 | CLANG_WARN_INT_CONVERSION = YES; 183 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 184 | CLANG_WARN_UNREACHABLE_CODE = YES; 185 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 186 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 187 | COPY_PHASE_STRIP = NO; 188 | DEBUG_INFORMATION_FORMAT = dwarf; 189 | ENABLE_STRICT_OBJC_MSGSEND = YES; 190 | ENABLE_TESTABILITY = YES; 191 | GCC_C_LANGUAGE_STANDARD = gnu99; 192 | GCC_DYNAMIC_NO_PIC = NO; 193 | GCC_NO_COMMON_BLOCKS = YES; 194 | GCC_OPTIMIZATION_LEVEL = 0; 195 | GCC_PREPROCESSOR_DEFINITIONS = ( 196 | "DEBUG=1", 197 | "$(inherited)", 198 | ); 199 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 200 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 201 | GCC_WARN_UNDECLARED_SELECTOR = YES; 202 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 203 | GCC_WARN_UNUSED_FUNCTION = YES; 204 | GCC_WARN_UNUSED_VARIABLE = YES; 205 | IPHONEOS_DEPLOYMENT_TARGET = 9.1; 206 | MTL_ENABLE_DEBUG_INFO = YES; 207 | ONLY_ACTIVE_ARCH = YES; 208 | SDKROOT = iphoneos; 209 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 210 | TARGETED_DEVICE_FAMILY = "1,2"; 211 | }; 212 | name = Debug; 213 | }; 214 | 6295598D1C01AA6D0004453C /* Release */ = { 215 | isa = XCBuildConfiguration; 216 | buildSettings = { 217 | ALWAYS_SEARCH_USER_PATHS = NO; 218 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 219 | CLANG_CXX_LIBRARY = "libc++"; 220 | CLANG_ENABLE_MODULES = YES; 221 | CLANG_ENABLE_OBJC_ARC = YES; 222 | CLANG_WARN_BOOL_CONVERSION = YES; 223 | CLANG_WARN_CONSTANT_CONVERSION = YES; 224 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 225 | CLANG_WARN_EMPTY_BODY = YES; 226 | CLANG_WARN_ENUM_CONVERSION = YES; 227 | CLANG_WARN_INT_CONVERSION = YES; 228 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 229 | CLANG_WARN_UNREACHABLE_CODE = YES; 230 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 231 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 232 | COPY_PHASE_STRIP = NO; 233 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 234 | ENABLE_NS_ASSERTIONS = NO; 235 | ENABLE_STRICT_OBJC_MSGSEND = YES; 236 | GCC_C_LANGUAGE_STANDARD = gnu99; 237 | GCC_NO_COMMON_BLOCKS = YES; 238 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 239 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 240 | GCC_WARN_UNDECLARED_SELECTOR = YES; 241 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 242 | GCC_WARN_UNUSED_FUNCTION = YES; 243 | GCC_WARN_UNUSED_VARIABLE = YES; 244 | IPHONEOS_DEPLOYMENT_TARGET = 9.1; 245 | MTL_ENABLE_DEBUG_INFO = NO; 246 | SDKROOT = iphoneos; 247 | TARGETED_DEVICE_FAMILY = "1,2"; 248 | VALIDATE_PRODUCT = YES; 249 | }; 250 | name = Release; 251 | }; 252 | 6295598F1C01AA6D0004453C /* Debug */ = { 253 | isa = XCBuildConfiguration; 254 | buildSettings = { 255 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 256 | INFOPLIST_FILE = KDQRCodeShow/Info.plist; 257 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 258 | PRODUCT_BUNDLE_IDENTIFIER = com.kingiol.KDQRCodeShow; 259 | PRODUCT_NAME = "$(TARGET_NAME)"; 260 | }; 261 | name = Debug; 262 | }; 263 | 629559901C01AA6D0004453C /* Release */ = { 264 | isa = XCBuildConfiguration; 265 | buildSettings = { 266 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 267 | INFOPLIST_FILE = KDQRCodeShow/Info.plist; 268 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 269 | PRODUCT_BUNDLE_IDENTIFIER = com.kingiol.KDQRCodeShow; 270 | PRODUCT_NAME = "$(TARGET_NAME)"; 271 | }; 272 | name = Release; 273 | }; 274 | /* End XCBuildConfiguration section */ 275 | 276 | /* Begin XCConfigurationList section */ 277 | 629559771C01AA6D0004453C /* Build configuration list for PBXProject "KDQRCodeShow" */ = { 278 | isa = XCConfigurationList; 279 | buildConfigurations = ( 280 | 6295598C1C01AA6D0004453C /* Debug */, 281 | 6295598D1C01AA6D0004453C /* Release */, 282 | ); 283 | defaultConfigurationIsVisible = 0; 284 | defaultConfigurationName = Release; 285 | }; 286 | 6295598E1C01AA6D0004453C /* Build configuration list for PBXNativeTarget "KDQRCodeShow" */ = { 287 | isa = XCConfigurationList; 288 | buildConfigurations = ( 289 | 6295598F1C01AA6D0004453C /* Debug */, 290 | 629559901C01AA6D0004453C /* Release */, 291 | ); 292 | defaultConfigurationIsVisible = 0; 293 | }; 294 | /* End XCConfigurationList section */ 295 | }; 296 | rootObject = 629559741C01AA6D0004453C /* Project object */; 297 | } 298 | -------------------------------------------------------------------------------- /KDQRCodeShow.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /KDQRCodeShow.xcodeproj/project.xcworkspace/xcuserdata/kingiol.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kingiol/KDQRCodeShow/4656b03a447685f93f4b0c25cbb95853a6acbb11/KDQRCodeShow.xcodeproj/project.xcworkspace/xcuserdata/kingiol.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /KDQRCodeShow.xcodeproj/xcuserdata/kingiol.xcuserdatad/xcschemes/KDQRCodeShow.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 | -------------------------------------------------------------------------------- /KDQRCodeShow.xcodeproj/xcuserdata/kingiol.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | KDQRCodeShow.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 6295597B1C01AA6D0004453C 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /KDQRCodeShow/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // KDQRCodeShow 4 | // 5 | // Created by Kingiol on 15/11/22. 6 | // Copyright © 2015年 Kingiol. 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: [NSObject: AnyObject]?) -> 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 throttle down OpenGL ES frame rates. 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 inactive 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 | -------------------------------------------------------------------------------- /KDQRCodeShow/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 | } -------------------------------------------------------------------------------- /KDQRCodeShow/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 | -------------------------------------------------------------------------------- /KDQRCodeShow/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /KDQRCodeShow/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 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /KDQRCodeShow/QRCodeViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // QRCodeViewController.swift 3 | // KDQRCodeShow 4 | // 5 | // Created by Kingiol on 15/11/22. 6 | // Copyright © 2015年 Kingiol. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | import AVFoundation 12 | 13 | class QRCodeViewController: UIViewController { 14 | 15 | var session: AVCaptureSession? 16 | 17 | let scanSize = CGSize(width: 200.0, height: 200.0) 18 | 19 | var contentW: CGFloat = 0.0 20 | var contentH: CGFloat = 0.0 21 | 22 | override func viewDidLoad() { 23 | super.viewDidLoad() 24 | 25 | // Do any additional setup after loading the view. 26 | title = "QRCodeShow" 27 | 28 | let screenSize = UIScreen.mainScreen().bounds.size 29 | contentW = screenSize.width 30 | contentH = screenSize.height 31 | 32 | setUpCamera() 33 | setUpQRMask() 34 | } 35 | 36 | override func viewDidAppear(animated: Bool) { 37 | super.viewDidAppear(animated) 38 | session?.startRunning() 39 | } 40 | 41 | override func viewDidDisappear(animated: Bool) { 42 | super.viewDidDisappear(animated) 43 | session?.stopRunning() 44 | } 45 | 46 | override func didReceiveMemoryWarning() { 47 | super.didReceiveMemoryWarning() 48 | // Dispose of any resources that can be recreated. 49 | } 50 | 51 | 52 | /* 53 | // MARK: - Navigation 54 | 55 | // In a storyboard-based application, you will often want to do a little preparation before navigation 56 | override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { 57 | // Get the new view controller using segue.destinationViewController. 58 | // Pass the selected object to the new view controller. 59 | } 60 | */ 61 | 62 | } 63 | 64 | // MARK: AVCaptureMetadataOutputObjectsDelegate 65 | 66 | extension QRCodeViewController: AVCaptureMetadataOutputObjectsDelegate { 67 | 68 | func captureOutput(captureOutput: AVCaptureOutput!, didOutputMetadataObjects metadataObjects: [AnyObject]!, fromConnection connection: AVCaptureConnection!) { 69 | var stringValue = "" 70 | if metadataObjects.count > 0 { 71 | let metaDataObject = metadataObjects[0] as! AVMetadataMachineReadableCodeObject 72 | if metaDataObject.type == AVMetadataObjectTypeQRCode { 73 | stringValue = metaDataObject.stringValue 74 | } 75 | } 76 | 77 | if stringValue.characters.count > 0 { 78 | session?.stopRunning() 79 | print("QRCode: \(stringValue)") 80 | } 81 | } 82 | 83 | } 84 | 85 | // MARK: Private Methods 86 | 87 | extension QRCodeViewController { 88 | 89 | func setUpCamera() { 90 | if checkCameraAvaliable() { 91 | if checkCameraAuthorise() { 92 | let device = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo) 93 | var input: AVCaptureDeviceInput; 94 | do { 95 | input = try AVCaptureDeviceInput(device: device) 96 | } catch let error as NSError { 97 | print("error:\(error.localizedDescription)") 98 | return 99 | } 100 | 101 | session = AVCaptureSession() 102 | session!.sessionPreset = AVCaptureSessionPresetHigh 103 | if session!.canAddInput(input) { 104 | session!.addInput(input) 105 | } 106 | 107 | let metaDataOutput = AVCaptureMetadataOutput() 108 | if session!.canAddOutput(metaDataOutput) { 109 | session!.addOutput(metaDataOutput) 110 | } 111 | 112 | let dispatchQueue = dispatch_queue_create("com.kingiol.QRLockQueue", nil) 113 | metaDataOutput.setMetadataObjectsDelegate(self, queue: dispatchQueue) 114 | metaDataOutput.metadataObjectTypes = [AVMetadataObjectTypeQRCode] 115 | 116 | var scanRect = CGRect(x: (contentW-scanSize.width)/2.0, y: (contentH-scanSize.height)/2.0, width: scanSize.width, height: scanSize.height) 117 | 118 | scanRect = CGRect(x: scanRect.origin.y/contentH, y: scanRect.origin.x/contentW, width: scanRect.size.height/contentH, height: scanRect.size.width/contentW) 119 | 120 | metaDataOutput.rectOfInterest = scanRect 121 | 122 | let previewLayer = AVCaptureVideoPreviewLayer(session: session) 123 | previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill 124 | 125 | previewLayer.frame = view.bounds 126 | view.layer.insertSublayer(previewLayer, atIndex: 0) 127 | } 128 | }else { 129 | print("相机不可用") 130 | } 131 | } 132 | 133 | func setUpQRMask() { 134 | let centerRect = CGRect(x: (contentW-scanSize.width)/2.0, y: (contentH-scanSize.height)/2.0, width: scanSize.width, height: scanSize.height) 135 | 136 | let path = UIBezierPath(rect: view.bounds) 137 | let centerPath = UIBezierPath(rect: centerRect) 138 | path.appendPath(centerPath) 139 | path.usesEvenOddFillRule = true 140 | 141 | let fillLayer = CAShapeLayer() 142 | fillLayer.path = path.CGPath 143 | fillLayer.fillRule = kCAFillRuleEvenOdd 144 | fillLayer.fillColor = UIColor.blackColor().colorWithAlphaComponent(0.3).CGColor 145 | view.layer.addSublayer(fillLayer) 146 | } 147 | 148 | func checkCameraAvaliable() -> Bool { 149 | return UIImagePickerController.isSourceTypeAvailable(.Camera); 150 | } 151 | 152 | func checkCameraAuthorise() -> Bool { 153 | let status = AVCaptureDevice.authorizationStatusForMediaType(AVMediaTypeVideo) 154 | if status == .Restricted || status == .Denied { 155 | 156 | let alertActionController = UIAlertController(title: "", message: nil, preferredStyle: .Alert) 157 | 158 | let message: String 159 | 160 | switch UIDevice.currentDevice().systemVersion.compare("8.0.0", options: NSStringCompareOptions.NumericSearch) { 161 | case .OrderedSame, .OrderedDescending: 162 | message = "请在设备的\"设置-隐私-相机\"中允许访问相机。" 163 | alertActionController.addAction(UIAlertAction(title: "取消", style: .Cancel, handler: nil)) 164 | alertActionController.addAction(UIAlertAction(title: "确定", style: .Default, handler: { _ -> Void in 165 | UIApplication.sharedApplication().openURL(NSURL(string: UIApplicationOpenSettingsURLString)!) 166 | })) 167 | case .OrderedAscending: 168 | // Do Nothing 169 | message = "请设置允许访问相机。" 170 | alertActionController.addAction(UIAlertAction(title: "确定", style: UIAlertActionStyle.Cancel, handler: nil)) 171 | } 172 | 173 | alertActionController.message = message 174 | 175 | presentViewController(alertActionController, animated: true, completion: nil) 176 | 177 | return false 178 | } 179 | return true 180 | } 181 | 182 | } -------------------------------------------------------------------------------- /KDQRCodeShow/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // KDQRCodeShow 4 | // 5 | // Created by Kingiol on 15/11/22. 6 | // Copyright © 2015年 Kingiol. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | // Do any additional setup after loading the view, typically from a nib. 16 | } 17 | 18 | override func didReceiveMemoryWarning() { 19 | super.didReceiveMemoryWarning() 20 | // Dispose of any resources that can be recreated. 21 | } 22 | 23 | 24 | } 25 | 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Kingiol 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 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # KDQRCodeShow 2 | 3 | support QRCode like wechat(微信) 4 | 5 | ![screenshot](./screenshot/screenshot.jpg) 6 | 7 | ## Requirements 8 | 9 | - iOS 8.0+ 10 | - Xcode 7.1+ 11 | 12 | ## Credits 13 | 14 | AHKNavigationController was created by [@Kingiol](https://github.com/kingiol). 15 | 16 | ## License 17 | 18 | KDQRCodeShow is released under the MIT license. See LICENSE for details. -------------------------------------------------------------------------------- /screenshot/screenshot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kingiol/KDQRCodeShow/4656b03a447685f93f4b0c25cbb95853a6acbb11/screenshot/screenshot.jpg --------------------------------------------------------------------------------