├── .gitignore ├── Demo-CustomQRCode.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── Demo-CustomQRCode ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── CustomQRCode.h ├── CustomQRCode.m ├── Info.plist ├── ViewController.h ├── ViewController.m └── main.m ├── README.md └── ScreenShot.png /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | Demo-CustomQRCode.xcodeproj/xcuserdata 3 | -------------------------------------------------------------------------------- /Demo-CustomQRCode.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | CBC754ED1D6AEFCB001A498D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = CBC754EC1D6AEFCB001A498D /* main.m */; }; 11 | CBC754F01D6AEFCB001A498D /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = CBC754EF1D6AEFCB001A498D /* AppDelegate.m */; }; 12 | CBC754F31D6AEFCB001A498D /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = CBC754F21D6AEFCB001A498D /* ViewController.m */; }; 13 | CBC754F61D6AEFCB001A498D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CBC754F41D6AEFCB001A498D /* Main.storyboard */; }; 14 | CBC754F81D6AEFCB001A498D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CBC754F71D6AEFCB001A498D /* Assets.xcassets */; }; 15 | CBC754FB1D6AEFCB001A498D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CBC754F91D6AEFCB001A498D /* LaunchScreen.storyboard */; }; 16 | CBC755041D6AF4A5001A498D /* CustomQRCode.m in Sources */ = {isa = PBXBuildFile; fileRef = CBC755031D6AF4A5001A498D /* CustomQRCode.m */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXFileReference section */ 20 | CBC754E81D6AEFCB001A498D /* Demo-CustomQRCode.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Demo-CustomQRCode.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 21 | CBC754EC1D6AEFCB001A498D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 22 | CBC754EE1D6AEFCB001A498D /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 23 | CBC754EF1D6AEFCB001A498D /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 24 | CBC754F11D6AEFCB001A498D /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 25 | CBC754F21D6AEFCB001A498D /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 26 | CBC754F51D6AEFCB001A498D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 27 | CBC754F71D6AEFCB001A498D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 28 | CBC754FA1D6AEFCB001A498D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 29 | CBC754FC1D6AEFCB001A498D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 30 | CBC755021D6AF4A5001A498D /* CustomQRCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomQRCode.h; sourceTree = ""; }; 31 | CBC755031D6AF4A5001A498D /* CustomQRCode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CustomQRCode.m; sourceTree = ""; }; 32 | /* End PBXFileReference section */ 33 | 34 | /* Begin PBXFrameworksBuildPhase section */ 35 | CBC754E51D6AEFCB001A498D /* Frameworks */ = { 36 | isa = PBXFrameworksBuildPhase; 37 | buildActionMask = 2147483647; 38 | files = ( 39 | ); 40 | runOnlyForDeploymentPostprocessing = 0; 41 | }; 42 | /* End PBXFrameworksBuildPhase section */ 43 | 44 | /* Begin PBXGroup section */ 45 | CBC754DF1D6AEFCB001A498D = { 46 | isa = PBXGroup; 47 | children = ( 48 | CBC754EA1D6AEFCB001A498D /* Demo-CustomQRCode */, 49 | CBC754E91D6AEFCB001A498D /* Products */, 50 | ); 51 | sourceTree = ""; 52 | }; 53 | CBC754E91D6AEFCB001A498D /* Products */ = { 54 | isa = PBXGroup; 55 | children = ( 56 | CBC754E81D6AEFCB001A498D /* Demo-CustomQRCode.app */, 57 | ); 58 | name = Products; 59 | sourceTree = ""; 60 | }; 61 | CBC754EA1D6AEFCB001A498D /* Demo-CustomQRCode */ = { 62 | isa = PBXGroup; 63 | children = ( 64 | CBC754EE1D6AEFCB001A498D /* AppDelegate.h */, 65 | CBC754EF1D6AEFCB001A498D /* AppDelegate.m */, 66 | CBC754F11D6AEFCB001A498D /* ViewController.h */, 67 | CBC754F21D6AEFCB001A498D /* ViewController.m */, 68 | CBC754F41D6AEFCB001A498D /* Main.storyboard */, 69 | CBC754F71D6AEFCB001A498D /* Assets.xcassets */, 70 | CBC754F91D6AEFCB001A498D /* LaunchScreen.storyboard */, 71 | CBC754FC1D6AEFCB001A498D /* Info.plist */, 72 | CBC754EB1D6AEFCB001A498D /* Supporting Files */, 73 | CBC755021D6AF4A5001A498D /* CustomQRCode.h */, 74 | CBC755031D6AF4A5001A498D /* CustomQRCode.m */, 75 | ); 76 | path = "Demo-CustomQRCode"; 77 | sourceTree = ""; 78 | }; 79 | CBC754EB1D6AEFCB001A498D /* Supporting Files */ = { 80 | isa = PBXGroup; 81 | children = ( 82 | CBC754EC1D6AEFCB001A498D /* main.m */, 83 | ); 84 | name = "Supporting Files"; 85 | sourceTree = ""; 86 | }; 87 | /* End PBXGroup section */ 88 | 89 | /* Begin PBXNativeTarget section */ 90 | CBC754E71D6AEFCB001A498D /* Demo-CustomQRCode */ = { 91 | isa = PBXNativeTarget; 92 | buildConfigurationList = CBC754FF1D6AEFCB001A498D /* Build configuration list for PBXNativeTarget "Demo-CustomQRCode" */; 93 | buildPhases = ( 94 | CBC754E41D6AEFCB001A498D /* Sources */, 95 | CBC754E51D6AEFCB001A498D /* Frameworks */, 96 | CBC754E61D6AEFCB001A498D /* Resources */, 97 | ); 98 | buildRules = ( 99 | ); 100 | dependencies = ( 101 | ); 102 | name = "Demo-CustomQRCode"; 103 | productName = "Demo-CustomQRCode"; 104 | productReference = CBC754E81D6AEFCB001A498D /* Demo-CustomQRCode.app */; 105 | productType = "com.apple.product-type.application"; 106 | }; 107 | /* End PBXNativeTarget section */ 108 | 109 | /* Begin PBXProject section */ 110 | CBC754E01D6AEFCB001A498D /* Project object */ = { 111 | isa = PBXProject; 112 | attributes = { 113 | LastUpgradeCheck = 0730; 114 | ORGANIZATIONNAME = Yourtion; 115 | TargetAttributes = { 116 | CBC754E71D6AEFCB001A498D = { 117 | CreatedOnToolsVersion = 7.3.1; 118 | }; 119 | }; 120 | }; 121 | buildConfigurationList = CBC754E31D6AEFCB001A498D /* Build configuration list for PBXProject "Demo-CustomQRCode" */; 122 | compatibilityVersion = "Xcode 3.2"; 123 | developmentRegion = English; 124 | hasScannedForEncodings = 0; 125 | knownRegions = ( 126 | en, 127 | Base, 128 | ); 129 | mainGroup = CBC754DF1D6AEFCB001A498D; 130 | productRefGroup = CBC754E91D6AEFCB001A498D /* Products */; 131 | projectDirPath = ""; 132 | projectRoot = ""; 133 | targets = ( 134 | CBC754E71D6AEFCB001A498D /* Demo-CustomQRCode */, 135 | ); 136 | }; 137 | /* End PBXProject section */ 138 | 139 | /* Begin PBXResourcesBuildPhase section */ 140 | CBC754E61D6AEFCB001A498D /* Resources */ = { 141 | isa = PBXResourcesBuildPhase; 142 | buildActionMask = 2147483647; 143 | files = ( 144 | CBC754FB1D6AEFCB001A498D /* LaunchScreen.storyboard in Resources */, 145 | CBC754F81D6AEFCB001A498D /* Assets.xcassets in Resources */, 146 | CBC754F61D6AEFCB001A498D /* Main.storyboard in Resources */, 147 | ); 148 | runOnlyForDeploymentPostprocessing = 0; 149 | }; 150 | /* End PBXResourcesBuildPhase section */ 151 | 152 | /* Begin PBXSourcesBuildPhase section */ 153 | CBC754E41D6AEFCB001A498D /* Sources */ = { 154 | isa = PBXSourcesBuildPhase; 155 | buildActionMask = 2147483647; 156 | files = ( 157 | CBC754F31D6AEFCB001A498D /* ViewController.m in Sources */, 158 | CBC754F01D6AEFCB001A498D /* AppDelegate.m in Sources */, 159 | CBC755041D6AF4A5001A498D /* CustomQRCode.m in Sources */, 160 | CBC754ED1D6AEFCB001A498D /* main.m in Sources */, 161 | ); 162 | runOnlyForDeploymentPostprocessing = 0; 163 | }; 164 | /* End PBXSourcesBuildPhase section */ 165 | 166 | /* Begin PBXVariantGroup section */ 167 | CBC754F41D6AEFCB001A498D /* Main.storyboard */ = { 168 | isa = PBXVariantGroup; 169 | children = ( 170 | CBC754F51D6AEFCB001A498D /* Base */, 171 | ); 172 | name = Main.storyboard; 173 | sourceTree = ""; 174 | }; 175 | CBC754F91D6AEFCB001A498D /* LaunchScreen.storyboard */ = { 176 | isa = PBXVariantGroup; 177 | children = ( 178 | CBC754FA1D6AEFCB001A498D /* Base */, 179 | ); 180 | name = LaunchScreen.storyboard; 181 | sourceTree = ""; 182 | }; 183 | /* End PBXVariantGroup section */ 184 | 185 | /* Begin XCBuildConfiguration section */ 186 | CBC754FD1D6AEFCB001A498D /* Debug */ = { 187 | isa = XCBuildConfiguration; 188 | buildSettings = { 189 | ALWAYS_SEARCH_USER_PATHS = NO; 190 | CLANG_ANALYZER_NONNULL = YES; 191 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 192 | CLANG_CXX_LIBRARY = "libc++"; 193 | CLANG_ENABLE_MODULES = YES; 194 | CLANG_ENABLE_OBJC_ARC = YES; 195 | CLANG_WARN_BOOL_CONVERSION = YES; 196 | CLANG_WARN_CONSTANT_CONVERSION = YES; 197 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 198 | CLANG_WARN_EMPTY_BODY = YES; 199 | CLANG_WARN_ENUM_CONVERSION = YES; 200 | CLANG_WARN_INT_CONVERSION = YES; 201 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 202 | CLANG_WARN_UNREACHABLE_CODE = YES; 203 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 204 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 205 | COPY_PHASE_STRIP = NO; 206 | DEBUG_INFORMATION_FORMAT = dwarf; 207 | ENABLE_STRICT_OBJC_MSGSEND = YES; 208 | ENABLE_TESTABILITY = YES; 209 | GCC_C_LANGUAGE_STANDARD = gnu99; 210 | GCC_DYNAMIC_NO_PIC = NO; 211 | GCC_NO_COMMON_BLOCKS = YES; 212 | GCC_OPTIMIZATION_LEVEL = 0; 213 | GCC_PREPROCESSOR_DEFINITIONS = ( 214 | "DEBUG=1", 215 | "$(inherited)", 216 | ); 217 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 218 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 219 | GCC_WARN_UNDECLARED_SELECTOR = YES; 220 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 221 | GCC_WARN_UNUSED_FUNCTION = YES; 222 | GCC_WARN_UNUSED_VARIABLE = YES; 223 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 224 | MTL_ENABLE_DEBUG_INFO = YES; 225 | ONLY_ACTIVE_ARCH = YES; 226 | SDKROOT = iphoneos; 227 | TARGETED_DEVICE_FAMILY = "1,2"; 228 | }; 229 | name = Debug; 230 | }; 231 | CBC754FE1D6AEFCB001A498D /* Release */ = { 232 | isa = XCBuildConfiguration; 233 | buildSettings = { 234 | ALWAYS_SEARCH_USER_PATHS = NO; 235 | CLANG_ANALYZER_NONNULL = YES; 236 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 237 | CLANG_CXX_LIBRARY = "libc++"; 238 | CLANG_ENABLE_MODULES = YES; 239 | CLANG_ENABLE_OBJC_ARC = YES; 240 | CLANG_WARN_BOOL_CONVERSION = YES; 241 | CLANG_WARN_CONSTANT_CONVERSION = YES; 242 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 243 | CLANG_WARN_EMPTY_BODY = YES; 244 | CLANG_WARN_ENUM_CONVERSION = YES; 245 | CLANG_WARN_INT_CONVERSION = YES; 246 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 247 | CLANG_WARN_UNREACHABLE_CODE = YES; 248 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 249 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 250 | COPY_PHASE_STRIP = NO; 251 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 252 | ENABLE_NS_ASSERTIONS = NO; 253 | ENABLE_STRICT_OBJC_MSGSEND = YES; 254 | GCC_C_LANGUAGE_STANDARD = gnu99; 255 | GCC_NO_COMMON_BLOCKS = YES; 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 = 9.3; 263 | MTL_ENABLE_DEBUG_INFO = NO; 264 | SDKROOT = iphoneos; 265 | TARGETED_DEVICE_FAMILY = "1,2"; 266 | VALIDATE_PRODUCT = YES; 267 | }; 268 | name = Release; 269 | }; 270 | CBC755001D6AEFCB001A498D /* Debug */ = { 271 | isa = XCBuildConfiguration; 272 | buildSettings = { 273 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 274 | INFOPLIST_FILE = "Demo-CustomQRCode/Info.plist"; 275 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 276 | PRODUCT_BUNDLE_IDENTIFIER = "com.yourtion.Demo-CustomQRCode"; 277 | PRODUCT_NAME = "$(TARGET_NAME)"; 278 | }; 279 | name = Debug; 280 | }; 281 | CBC755011D6AEFCB001A498D /* Release */ = { 282 | isa = XCBuildConfiguration; 283 | buildSettings = { 284 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 285 | INFOPLIST_FILE = "Demo-CustomQRCode/Info.plist"; 286 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 287 | PRODUCT_BUNDLE_IDENTIFIER = "com.yourtion.Demo-CustomQRCode"; 288 | PRODUCT_NAME = "$(TARGET_NAME)"; 289 | }; 290 | name = Release; 291 | }; 292 | /* End XCBuildConfiguration section */ 293 | 294 | /* Begin XCConfigurationList section */ 295 | CBC754E31D6AEFCB001A498D /* Build configuration list for PBXProject "Demo-CustomQRCode" */ = { 296 | isa = XCConfigurationList; 297 | buildConfigurations = ( 298 | CBC754FD1D6AEFCB001A498D /* Debug */, 299 | CBC754FE1D6AEFCB001A498D /* Release */, 300 | ); 301 | defaultConfigurationIsVisible = 0; 302 | defaultConfigurationName = Release; 303 | }; 304 | CBC754FF1D6AEFCB001A498D /* Build configuration list for PBXNativeTarget "Demo-CustomQRCode" */ = { 305 | isa = XCConfigurationList; 306 | buildConfigurations = ( 307 | CBC755001D6AEFCB001A498D /* Debug */, 308 | CBC755011D6AEFCB001A498D /* Release */, 309 | ); 310 | defaultConfigurationIsVisible = 0; 311 | defaultConfigurationName = Release; 312 | }; 313 | /* End XCConfigurationList section */ 314 | }; 315 | rootObject = CBC754E01D6AEFCB001A498D /* Project object */; 316 | } 317 | -------------------------------------------------------------------------------- /Demo-CustomQRCode.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Demo-CustomQRCode/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // Demo-CustomQRCode 4 | // 5 | // Created by YourtionGuo on 8/22/16. 6 | // Copyright © 2016 Yourtion. 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 | -------------------------------------------------------------------------------- /Demo-CustomQRCode/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // Demo-CustomQRCode 4 | // 5 | // Created by YourtionGuo on 8/22/16. 6 | // Copyright © 2016 Yourtion. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /Demo-CustomQRCode/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 | } -------------------------------------------------------------------------------- /Demo-CustomQRCode/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 | -------------------------------------------------------------------------------- /Demo-CustomQRCode/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 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /Demo-CustomQRCode/CustomQRCode.h: -------------------------------------------------------------------------------- 1 | // 2 | // CustomQRCode.h 3 | // Demo-CustomQRCode 4 | // 5 | // Created by YourtionGuo on 8/22/16. 6 | // Copyright © 2016 Yourtion. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface CustomQRCode : NSObject 13 | 14 | + (UIImage *)generateCustomQRCode:(NSString *)string andSize:(CGFloat)size andColor:(UIColor *)color; 15 | 16 | + (void)setImageViewShadow:(UIImageView *)view; 17 | 18 | + (CIImage *)createQRForString:(NSString *)qrString; 19 | + (UIImage *)createNonInterpolatedUIImageFormCIImage:(CIImage *)image withSize:(CGFloat)size; 20 | + (UIImage*)imageBlackToTransparent:(UIImage*)image withRed:(CGFloat)red andGreen:(CGFloat)green andBlue:(CGFloat)blue; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /Demo-CustomQRCode/CustomQRCode.m: -------------------------------------------------------------------------------- 1 | // 2 | // CustomQRCode.m 3 | // Demo-CustomQRCode 4 | // 5 | // Created by YourtionGuo on 8/22/16. 6 | // Copyright © 2016 Yourtion. All rights reserved. 7 | // 8 | 9 | #import "CustomQRCode.h" 10 | 11 | @implementation CustomQRCode 12 | 13 | + (UIImage *)generateCustomQRCode:(NSString *)string andSize:(CGFloat)size andColor:(UIColor *)color { 14 | UIImage *qrcode = [CustomQRCode createNonInterpolatedUIImageFormCIImage:[CustomQRCode createQRForString:string] withSize:size]; 15 | const CGFloat *_components = CGColorGetComponents(color.CGColor); 16 | CGFloat red = _components[0] * 255.f; 17 | CGFloat green = _components[1] * 255.f; 18 | CGFloat blue = _components[2] * 255.f; 19 | return [CustomQRCode imageBlackToTransparent:qrcode withRed:red andGreen:green andBlue:blue]; 20 | } 21 | 22 | + (void)setImageViewShadow:(UIImageView *)view { 23 | view.layer.shadowOffset = CGSizeMake(0, 2); 24 | view.layer.shadowRadius = 2; 25 | view.layer.shadowColor = [UIColor blackColor].CGColor; 26 | view.layer.shadowOpacity = 0.5; 27 | } 28 | 29 | #pragma mark - InterpolatedUIImage 30 | + (UIImage *)createNonInterpolatedUIImageFormCIImage:(CIImage *)image withSize:(CGFloat)size { 31 | CGRect extent = CGRectIntegral(image.extent); 32 | CGFloat scale = MIN(size/CGRectGetWidth(extent), size/CGRectGetHeight(extent)); 33 | // create a bitmap image that we'll draw into a bitmap context at the desired size; 34 | size_t width = CGRectGetWidth(extent) * scale; 35 | size_t height = CGRectGetHeight(extent) * scale; 36 | CGColorSpaceRef cs = CGColorSpaceCreateDeviceGray(); 37 | CGContextRef bitmapRef = CGBitmapContextCreate(nil, width, height, 8, 0, cs, (CGBitmapInfo)kCGImageAlphaNone); 38 | CIContext *context = [CIContext contextWithOptions:nil]; 39 | CGImageRef bitmapImage = [context createCGImage:image fromRect:extent]; 40 | CGContextSetInterpolationQuality(bitmapRef, kCGInterpolationNone); 41 | CGContextScaleCTM(bitmapRef, scale, scale); 42 | CGContextDrawImage(bitmapRef, extent, bitmapImage); 43 | // Create an image with the contents of our bitmap 44 | CGImageRef scaledImage = CGBitmapContextCreateImage(bitmapRef); 45 | // Cleanup 46 | CGContextRelease(bitmapRef); 47 | CGImageRelease(bitmapImage); 48 | return [UIImage imageWithCGImage:scaledImage]; 49 | } 50 | 51 | #pragma mark - QRCodeGenerator 52 | + (CIImage *)createQRForString:(NSString *)qrString { 53 | // Need to convert the string to a UTF-8 encoded NSData object 54 | NSData *stringData = [qrString dataUsingEncoding:NSUTF8StringEncoding]; 55 | // Create the filter 56 | CIFilter *qrFilter = [CIFilter filterWithName:@"CIQRCodeGenerator"]; 57 | // Set the message content and error-correction level 58 | [qrFilter setValue:stringData forKey:@"inputMessage"]; 59 | [qrFilter setValue:@"M" forKey:@"inputCorrectionLevel"]; 60 | // Send the image back 61 | return qrFilter.outputImage; 62 | } 63 | 64 | #pragma mark - imageToTransparent 65 | 66 | void ProviderReleaseData (void *info, const void *data, size_t size){ 67 | free((void*)data); 68 | } 69 | 70 | + (UIImage*)imageBlackToTransparent:(UIImage*)image withRed:(CGFloat)red andGreen:(CGFloat)green andBlue:(CGFloat)blue{ 71 | const int imageWidth = image.size.width; 72 | const int imageHeight = image.size.height; 73 | size_t bytesPerRow = imageWidth * 4; 74 | uint32_t* rgbImageBuf = (uint32_t*)malloc(bytesPerRow * imageHeight); 75 | // create context 76 | CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); 77 | CGContextRef context = CGBitmapContextCreate(rgbImageBuf, imageWidth, imageHeight, 8, bytesPerRow, colorSpace, 78 | kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipLast); 79 | CGContextDrawImage(context, CGRectMake(0, 0, imageWidth, imageHeight), image.CGImage); 80 | // traverse pixe 81 | int pixelNum = imageWidth * imageHeight; 82 | uint32_t* pCurPtr = rgbImageBuf; 83 | for (int i = 0; i < pixelNum; i++, pCurPtr++){ 84 | if ((*pCurPtr & 0xFFFFFF00) < 0x99999900){ 85 | // change color 86 | uint8_t* ptr = (uint8_t*)pCurPtr; 87 | ptr[3] = red; //0~255 88 | ptr[2] = green; 89 | ptr[1] = blue; 90 | }else{ 91 | uint8_t* ptr = (uint8_t*)pCurPtr; 92 | ptr[0] = 0; 93 | } 94 | } 95 | // context to image 96 | CGDataProviderRef dataProvider = CGDataProviderCreateWithData(NULL, rgbImageBuf, bytesPerRow * imageHeight, ProviderReleaseData); 97 | CGImageRef imageRef = CGImageCreate(imageWidth, imageHeight, 8, 32, bytesPerRow, colorSpace, 98 | kCGImageAlphaLast | kCGBitmapByteOrder32Little, dataProvider, 99 | NULL, true, kCGRenderingIntentDefault); 100 | CGDataProviderRelease(dataProvider); 101 | UIImage* resultUIImage = [UIImage imageWithCGImage:imageRef]; 102 | // release 103 | CGImageRelease(imageRef); 104 | CGContextRelease(context); 105 | CGColorSpaceRelease(colorSpace); 106 | return resultUIImage; 107 | } 108 | 109 | @end 110 | -------------------------------------------------------------------------------- /Demo-CustomQRCode/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 | -------------------------------------------------------------------------------- /Demo-CustomQRCode/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // Demo-CustomQRCore 4 | // 5 | // Created by YourtionGuo on 6/5/14. 6 | // Copyright (c) 2014 yourtion. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /Demo-CustomQRCode/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // Demo-CustomQRCore 4 | // 5 | // Created by YourtionGuo on 6/5/14. 6 | // Copyright (c) 2014 yourtion. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "CustomQRCode.h" 11 | 12 | @interface ViewController () 13 | @property (strong, nonatomic) IBOutlet UIImageView *qrcodeView; 14 | @end 15 | 16 | @implementation ViewController 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | 21 | // Do any additional setup after loading the view, typically from a nib. 22 | 23 | // Only one line 24 | UIColor *customColor = [UIColor colorWithRed:60.f/255.f green:74.f/255.f blue:89.f/255.f alpha:1.f]; 25 | UIImage *customQrcode = [CustomQRCode generateCustomQRCode:@"http://blog.yourtion.com" andSize:250.f andColor:customColor]; 26 | 27 | // Old method 28 | // CIImage *qrcodeCg = [CustomQRCode createQRForString:@"http://blog.yourtion.com"]; 29 | // UIImage *qrcode = [CustomQRCode createNonInterpolatedUIImageFormCIImage:qrcodeCg withSize:250.0f]; 30 | // UIImage *customQrcode = [CustomQRCode imageBlackToTransparent:qrcode withRed:60.0f andGreen:74.0f andBlue:89.0f]; 31 | 32 | self.qrcodeView.image = customQrcode; 33 | // set shadow 34 | [CustomQRCode setImageViewShadow:self.qrcodeView]; 35 | // self.qrcodeView.layer.shadowOffset = CGSizeMake(0, 2); 36 | // self.qrcodeView.layer.shadowRadius = 2; 37 | // self.qrcodeView.layer.shadowColor = [UIColor blackColor].CGColor; 38 | // self.qrcodeView.layer.shadowOpacity = 0.5; 39 | } 40 | 41 | - (void)didReceiveMemoryWarning { 42 | [super didReceiveMemoryWarning]; 43 | // Dispose of any resources that can be recreated. 44 | } 45 | @end 46 | -------------------------------------------------------------------------------- /Demo-CustomQRCode/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // Demo-CustomQRCode 4 | // 5 | // Created by YourtionGuo on 8/22/16. 6 | // Copyright © 2016 Yourtion. 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Demo-CustomQRCode 2 | ================= 3 | 4 | Demo for CustomQRCode( http://blog.yourtion.com/custom-cifilter-qrcode-generator.html ) 5 | 6 | Generate a colorful QRCode using CIFilter with Objective-C. 7 | 8 | ScreenShot: 9 | 10 | ![](ScreenShot.png) 11 | -------------------------------------------------------------------------------- /ScreenShot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/Demo_CustomQRCode/66e546c8d5cccd548c6d2faf69fa1c960d7aa4d9/ScreenShot.png --------------------------------------------------------------------------------