├── DemoFigure ├── 111.gif └── 222.gif ├── LICENSE ├── NNValidationCodeView.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ ├── edz.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ │ └── yizhilu.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ ├── edz.xcuserdatad │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ │ ├── NNValidationCodeView.xcscheme │ │ └── xcschememanagement.plist │ └── yizhilu.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── NNValidationCodeView ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── NNValidationCodeView │ ├── NNValidationCodeView.h │ └── NNValidationCodeView.m ├── ViewController.h ├── ViewController.m └── main.m ├── NNValidationCodeViewTests ├── Info.plist └── NNValidationCodeViewTests.m ├── NNValidationCodeViewUITests ├── Info.plist └── NNValidationCodeViewUITests.m └── README.md /DemoFigure/111.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LiuPengKun1993/NNValidationCodeView/02c186e21b4f43e13151fadd6df410602b04b744/DemoFigure/111.gif -------------------------------------------------------------------------------- /DemoFigure/222.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LiuPengKun1993/NNValidationCodeView/02c186e21b4f43e13151fadd6df410602b04b744/DemoFigure/222.gif -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 以梦为马 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 | -------------------------------------------------------------------------------- /NNValidationCodeView.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 00F668801F1C8F79003F55F2 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 00F6687F1F1C8F79003F55F2 /* main.m */; }; 11 | 00F668831F1C8F79003F55F2 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 00F668821F1C8F79003F55F2 /* AppDelegate.m */; }; 12 | 00F668861F1C8F79003F55F2 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 00F668851F1C8F79003F55F2 /* ViewController.m */; }; 13 | 00F668891F1C8F79003F55F2 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 00F668871F1C8F79003F55F2 /* Main.storyboard */; }; 14 | 00F6688B1F1C8F79003F55F2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 00F6688A1F1C8F79003F55F2 /* Assets.xcassets */; }; 15 | 00F6688E1F1C8F79003F55F2 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 00F6688C1F1C8F79003F55F2 /* LaunchScreen.storyboard */; }; 16 | 00F668991F1C8F79003F55F2 /* NNValidationCodeViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00F668981F1C8F79003F55F2 /* NNValidationCodeViewTests.m */; }; 17 | 00F668A41F1C8F79003F55F2 /* NNValidationCodeViewUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00F668A31F1C8F79003F55F2 /* NNValidationCodeViewUITests.m */; }; 18 | 00F668B41F1C8FAE003F55F2 /* NNValidationCodeView.m in Sources */ = {isa = PBXBuildFile; fileRef = 00F668B31F1C8FAE003F55F2 /* NNValidationCodeView.m */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXContainerItemProxy section */ 22 | 00F668951F1C8F79003F55F2 /* PBXContainerItemProxy */ = { 23 | isa = PBXContainerItemProxy; 24 | containerPortal = 00F668731F1C8F79003F55F2 /* Project object */; 25 | proxyType = 1; 26 | remoteGlobalIDString = 00F6687A1F1C8F79003F55F2; 27 | remoteInfo = NNValidationCodeView; 28 | }; 29 | 00F668A01F1C8F79003F55F2 /* PBXContainerItemProxy */ = { 30 | isa = PBXContainerItemProxy; 31 | containerPortal = 00F668731F1C8F79003F55F2 /* Project object */; 32 | proxyType = 1; 33 | remoteGlobalIDString = 00F6687A1F1C8F79003F55F2; 34 | remoteInfo = NNValidationCodeView; 35 | }; 36 | /* End PBXContainerItemProxy section */ 37 | 38 | /* Begin PBXFileReference section */ 39 | 00F6687B1F1C8F79003F55F2 /* NNValidationCodeView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NNValidationCodeView.app; sourceTree = BUILT_PRODUCTS_DIR; }; 40 | 00F6687F1F1C8F79003F55F2 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 41 | 00F668811F1C8F79003F55F2 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 42 | 00F668821F1C8F79003F55F2 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 43 | 00F668841F1C8F79003F55F2 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 44 | 00F668851F1C8F79003F55F2 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 45 | 00F668881F1C8F79003F55F2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 46 | 00F6688A1F1C8F79003F55F2 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 47 | 00F6688D1F1C8F79003F55F2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 48 | 00F6688F1F1C8F79003F55F2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 49 | 00F668941F1C8F79003F55F2 /* NNValidationCodeViewTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NNValidationCodeViewTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 50 | 00F668981F1C8F79003F55F2 /* NNValidationCodeViewTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NNValidationCodeViewTests.m; sourceTree = ""; }; 51 | 00F6689A1F1C8F79003F55F2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 52 | 00F6689F1F1C8F79003F55F2 /* NNValidationCodeViewUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NNValidationCodeViewUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 53 | 00F668A31F1C8F79003F55F2 /* NNValidationCodeViewUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NNValidationCodeViewUITests.m; sourceTree = ""; }; 54 | 00F668A51F1C8F79003F55F2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 55 | 00F668B21F1C8FAE003F55F2 /* NNValidationCodeView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NNValidationCodeView.h; sourceTree = ""; }; 56 | 00F668B31F1C8FAE003F55F2 /* NNValidationCodeView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NNValidationCodeView.m; sourceTree = ""; }; 57 | /* End PBXFileReference section */ 58 | 59 | /* Begin PBXFrameworksBuildPhase section */ 60 | 00F668781F1C8F79003F55F2 /* Frameworks */ = { 61 | isa = PBXFrameworksBuildPhase; 62 | buildActionMask = 2147483647; 63 | files = ( 64 | ); 65 | runOnlyForDeploymentPostprocessing = 0; 66 | }; 67 | 00F668911F1C8F79003F55F2 /* Frameworks */ = { 68 | isa = PBXFrameworksBuildPhase; 69 | buildActionMask = 2147483647; 70 | files = ( 71 | ); 72 | runOnlyForDeploymentPostprocessing = 0; 73 | }; 74 | 00F6689C1F1C8F79003F55F2 /* Frameworks */ = { 75 | isa = PBXFrameworksBuildPhase; 76 | buildActionMask = 2147483647; 77 | files = ( 78 | ); 79 | runOnlyForDeploymentPostprocessing = 0; 80 | }; 81 | /* End PBXFrameworksBuildPhase section */ 82 | 83 | /* Begin PBXGroup section */ 84 | 00F668721F1C8F79003F55F2 = { 85 | isa = PBXGroup; 86 | children = ( 87 | 00F6687D1F1C8F79003F55F2 /* NNValidationCodeView */, 88 | 00F668971F1C8F79003F55F2 /* NNValidationCodeViewTests */, 89 | 00F668A21F1C8F79003F55F2 /* NNValidationCodeViewUITests */, 90 | 00F6687C1F1C8F79003F55F2 /* Products */, 91 | ); 92 | sourceTree = ""; 93 | }; 94 | 00F6687C1F1C8F79003F55F2 /* Products */ = { 95 | isa = PBXGroup; 96 | children = ( 97 | 00F6687B1F1C8F79003F55F2 /* NNValidationCodeView.app */, 98 | 00F668941F1C8F79003F55F2 /* NNValidationCodeViewTests.xctest */, 99 | 00F6689F1F1C8F79003F55F2 /* NNValidationCodeViewUITests.xctest */, 100 | ); 101 | name = Products; 102 | sourceTree = ""; 103 | }; 104 | 00F6687D1F1C8F79003F55F2 /* NNValidationCodeView */ = { 105 | isa = PBXGroup; 106 | children = ( 107 | 00F668B11F1C8F9A003F55F2 /* NNValidationCodeView */, 108 | 00F668811F1C8F79003F55F2 /* AppDelegate.h */, 109 | 00F668821F1C8F79003F55F2 /* AppDelegate.m */, 110 | 00F668841F1C8F79003F55F2 /* ViewController.h */, 111 | 00F668851F1C8F79003F55F2 /* ViewController.m */, 112 | 00F668871F1C8F79003F55F2 /* Main.storyboard */, 113 | 00F6688A1F1C8F79003F55F2 /* Assets.xcassets */, 114 | 00F6688C1F1C8F79003F55F2 /* LaunchScreen.storyboard */, 115 | 00F6688F1F1C8F79003F55F2 /* Info.plist */, 116 | 00F6687E1F1C8F79003F55F2 /* Supporting Files */, 117 | ); 118 | path = NNValidationCodeView; 119 | sourceTree = ""; 120 | }; 121 | 00F6687E1F1C8F79003F55F2 /* Supporting Files */ = { 122 | isa = PBXGroup; 123 | children = ( 124 | 00F6687F1F1C8F79003F55F2 /* main.m */, 125 | ); 126 | name = "Supporting Files"; 127 | sourceTree = ""; 128 | }; 129 | 00F668971F1C8F79003F55F2 /* NNValidationCodeViewTests */ = { 130 | isa = PBXGroup; 131 | children = ( 132 | 00F668981F1C8F79003F55F2 /* NNValidationCodeViewTests.m */, 133 | 00F6689A1F1C8F79003F55F2 /* Info.plist */, 134 | ); 135 | path = NNValidationCodeViewTests; 136 | sourceTree = ""; 137 | }; 138 | 00F668A21F1C8F79003F55F2 /* NNValidationCodeViewUITests */ = { 139 | isa = PBXGroup; 140 | children = ( 141 | 00F668A31F1C8F79003F55F2 /* NNValidationCodeViewUITests.m */, 142 | 00F668A51F1C8F79003F55F2 /* Info.plist */, 143 | ); 144 | path = NNValidationCodeViewUITests; 145 | sourceTree = ""; 146 | }; 147 | 00F668B11F1C8F9A003F55F2 /* NNValidationCodeView */ = { 148 | isa = PBXGroup; 149 | children = ( 150 | 00F668B21F1C8FAE003F55F2 /* NNValidationCodeView.h */, 151 | 00F668B31F1C8FAE003F55F2 /* NNValidationCodeView.m */, 152 | ); 153 | path = NNValidationCodeView; 154 | sourceTree = ""; 155 | }; 156 | /* End PBXGroup section */ 157 | 158 | /* Begin PBXNativeTarget section */ 159 | 00F6687A1F1C8F79003F55F2 /* NNValidationCodeView */ = { 160 | isa = PBXNativeTarget; 161 | buildConfigurationList = 00F668A81F1C8F79003F55F2 /* Build configuration list for PBXNativeTarget "NNValidationCodeView" */; 162 | buildPhases = ( 163 | 00F668771F1C8F79003F55F2 /* Sources */, 164 | 00F668781F1C8F79003F55F2 /* Frameworks */, 165 | 00F668791F1C8F79003F55F2 /* Resources */, 166 | ); 167 | buildRules = ( 168 | ); 169 | dependencies = ( 170 | ); 171 | name = NNValidationCodeView; 172 | productName = NNValidationCodeView; 173 | productReference = 00F6687B1F1C8F79003F55F2 /* NNValidationCodeView.app */; 174 | productType = "com.apple.product-type.application"; 175 | }; 176 | 00F668931F1C8F79003F55F2 /* NNValidationCodeViewTests */ = { 177 | isa = PBXNativeTarget; 178 | buildConfigurationList = 00F668AB1F1C8F79003F55F2 /* Build configuration list for PBXNativeTarget "NNValidationCodeViewTests" */; 179 | buildPhases = ( 180 | 00F668901F1C8F79003F55F2 /* Sources */, 181 | 00F668911F1C8F79003F55F2 /* Frameworks */, 182 | 00F668921F1C8F79003F55F2 /* Resources */, 183 | ); 184 | buildRules = ( 185 | ); 186 | dependencies = ( 187 | 00F668961F1C8F79003F55F2 /* PBXTargetDependency */, 188 | ); 189 | name = NNValidationCodeViewTests; 190 | productName = NNValidationCodeViewTests; 191 | productReference = 00F668941F1C8F79003F55F2 /* NNValidationCodeViewTests.xctest */; 192 | productType = "com.apple.product-type.bundle.unit-test"; 193 | }; 194 | 00F6689E1F1C8F79003F55F2 /* NNValidationCodeViewUITests */ = { 195 | isa = PBXNativeTarget; 196 | buildConfigurationList = 00F668AE1F1C8F79003F55F2 /* Build configuration list for PBXNativeTarget "NNValidationCodeViewUITests" */; 197 | buildPhases = ( 198 | 00F6689B1F1C8F79003F55F2 /* Sources */, 199 | 00F6689C1F1C8F79003F55F2 /* Frameworks */, 200 | 00F6689D1F1C8F79003F55F2 /* Resources */, 201 | ); 202 | buildRules = ( 203 | ); 204 | dependencies = ( 205 | 00F668A11F1C8F79003F55F2 /* PBXTargetDependency */, 206 | ); 207 | name = NNValidationCodeViewUITests; 208 | productName = NNValidationCodeViewUITests; 209 | productReference = 00F6689F1F1C8F79003F55F2 /* NNValidationCodeViewUITests.xctest */; 210 | productType = "com.apple.product-type.bundle.ui-testing"; 211 | }; 212 | /* End PBXNativeTarget section */ 213 | 214 | /* Begin PBXProject section */ 215 | 00F668731F1C8F79003F55F2 /* Project object */ = { 216 | isa = PBXProject; 217 | attributes = { 218 | CLASSPREFIX = NN; 219 | LastUpgradeCheck = 0830; 220 | ORGANIZATIONNAME = "刘朋坤"; 221 | TargetAttributes = { 222 | 00F6687A1F1C8F79003F55F2 = { 223 | CreatedOnToolsVersion = 8.3.2; 224 | ProvisioningStyle = Automatic; 225 | }; 226 | 00F668931F1C8F79003F55F2 = { 227 | CreatedOnToolsVersion = 8.3.2; 228 | ProvisioningStyle = Automatic; 229 | TestTargetID = 00F6687A1F1C8F79003F55F2; 230 | }; 231 | 00F6689E1F1C8F79003F55F2 = { 232 | CreatedOnToolsVersion = 8.3.2; 233 | ProvisioningStyle = Automatic; 234 | TestTargetID = 00F6687A1F1C8F79003F55F2; 235 | }; 236 | }; 237 | }; 238 | buildConfigurationList = 00F668761F1C8F79003F55F2 /* Build configuration list for PBXProject "NNValidationCodeView" */; 239 | compatibilityVersion = "Xcode 3.2"; 240 | developmentRegion = English; 241 | hasScannedForEncodings = 0; 242 | knownRegions = ( 243 | en, 244 | Base, 245 | ); 246 | mainGroup = 00F668721F1C8F79003F55F2; 247 | productRefGroup = 00F6687C1F1C8F79003F55F2 /* Products */; 248 | projectDirPath = ""; 249 | projectRoot = ""; 250 | targets = ( 251 | 00F6687A1F1C8F79003F55F2 /* NNValidationCodeView */, 252 | 00F668931F1C8F79003F55F2 /* NNValidationCodeViewTests */, 253 | 00F6689E1F1C8F79003F55F2 /* NNValidationCodeViewUITests */, 254 | ); 255 | }; 256 | /* End PBXProject section */ 257 | 258 | /* Begin PBXResourcesBuildPhase section */ 259 | 00F668791F1C8F79003F55F2 /* Resources */ = { 260 | isa = PBXResourcesBuildPhase; 261 | buildActionMask = 2147483647; 262 | files = ( 263 | 00F6688E1F1C8F79003F55F2 /* LaunchScreen.storyboard in Resources */, 264 | 00F6688B1F1C8F79003F55F2 /* Assets.xcassets in Resources */, 265 | 00F668891F1C8F79003F55F2 /* Main.storyboard in Resources */, 266 | ); 267 | runOnlyForDeploymentPostprocessing = 0; 268 | }; 269 | 00F668921F1C8F79003F55F2 /* Resources */ = { 270 | isa = PBXResourcesBuildPhase; 271 | buildActionMask = 2147483647; 272 | files = ( 273 | ); 274 | runOnlyForDeploymentPostprocessing = 0; 275 | }; 276 | 00F6689D1F1C8F79003F55F2 /* Resources */ = { 277 | isa = PBXResourcesBuildPhase; 278 | buildActionMask = 2147483647; 279 | files = ( 280 | ); 281 | runOnlyForDeploymentPostprocessing = 0; 282 | }; 283 | /* End PBXResourcesBuildPhase section */ 284 | 285 | /* Begin PBXSourcesBuildPhase section */ 286 | 00F668771F1C8F79003F55F2 /* Sources */ = { 287 | isa = PBXSourcesBuildPhase; 288 | buildActionMask = 2147483647; 289 | files = ( 290 | 00F668861F1C8F79003F55F2 /* ViewController.m in Sources */, 291 | 00F668831F1C8F79003F55F2 /* AppDelegate.m in Sources */, 292 | 00F668B41F1C8FAE003F55F2 /* NNValidationCodeView.m in Sources */, 293 | 00F668801F1C8F79003F55F2 /* main.m in Sources */, 294 | ); 295 | runOnlyForDeploymentPostprocessing = 0; 296 | }; 297 | 00F668901F1C8F79003F55F2 /* Sources */ = { 298 | isa = PBXSourcesBuildPhase; 299 | buildActionMask = 2147483647; 300 | files = ( 301 | 00F668991F1C8F79003F55F2 /* NNValidationCodeViewTests.m in Sources */, 302 | ); 303 | runOnlyForDeploymentPostprocessing = 0; 304 | }; 305 | 00F6689B1F1C8F79003F55F2 /* Sources */ = { 306 | isa = PBXSourcesBuildPhase; 307 | buildActionMask = 2147483647; 308 | files = ( 309 | 00F668A41F1C8F79003F55F2 /* NNValidationCodeViewUITests.m in Sources */, 310 | ); 311 | runOnlyForDeploymentPostprocessing = 0; 312 | }; 313 | /* End PBXSourcesBuildPhase section */ 314 | 315 | /* Begin PBXTargetDependency section */ 316 | 00F668961F1C8F79003F55F2 /* PBXTargetDependency */ = { 317 | isa = PBXTargetDependency; 318 | target = 00F6687A1F1C8F79003F55F2 /* NNValidationCodeView */; 319 | targetProxy = 00F668951F1C8F79003F55F2 /* PBXContainerItemProxy */; 320 | }; 321 | 00F668A11F1C8F79003F55F2 /* PBXTargetDependency */ = { 322 | isa = PBXTargetDependency; 323 | target = 00F6687A1F1C8F79003F55F2 /* NNValidationCodeView */; 324 | targetProxy = 00F668A01F1C8F79003F55F2 /* PBXContainerItemProxy */; 325 | }; 326 | /* End PBXTargetDependency section */ 327 | 328 | /* Begin PBXVariantGroup section */ 329 | 00F668871F1C8F79003F55F2 /* Main.storyboard */ = { 330 | isa = PBXVariantGroup; 331 | children = ( 332 | 00F668881F1C8F79003F55F2 /* Base */, 333 | ); 334 | name = Main.storyboard; 335 | sourceTree = ""; 336 | }; 337 | 00F6688C1F1C8F79003F55F2 /* LaunchScreen.storyboard */ = { 338 | isa = PBXVariantGroup; 339 | children = ( 340 | 00F6688D1F1C8F79003F55F2 /* Base */, 341 | ); 342 | name = LaunchScreen.storyboard; 343 | sourceTree = ""; 344 | }; 345 | /* End PBXVariantGroup section */ 346 | 347 | /* Begin XCBuildConfiguration section */ 348 | 00F668A61F1C8F79003F55F2 /* Debug */ = { 349 | isa = XCBuildConfiguration; 350 | buildSettings = { 351 | ALWAYS_SEARCH_USER_PATHS = NO; 352 | CLANG_ANALYZER_NONNULL = YES; 353 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 354 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 355 | CLANG_CXX_LIBRARY = "libc++"; 356 | CLANG_ENABLE_MODULES = YES; 357 | CLANG_ENABLE_OBJC_ARC = YES; 358 | CLANG_WARN_BOOL_CONVERSION = YES; 359 | CLANG_WARN_CONSTANT_CONVERSION = YES; 360 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 361 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 362 | CLANG_WARN_EMPTY_BODY = YES; 363 | CLANG_WARN_ENUM_CONVERSION = YES; 364 | CLANG_WARN_INFINITE_RECURSION = YES; 365 | CLANG_WARN_INT_CONVERSION = YES; 366 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 367 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 368 | CLANG_WARN_UNREACHABLE_CODE = YES; 369 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 370 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 371 | COPY_PHASE_STRIP = NO; 372 | DEBUG_INFORMATION_FORMAT = dwarf; 373 | ENABLE_STRICT_OBJC_MSGSEND = YES; 374 | ENABLE_TESTABILITY = YES; 375 | GCC_C_LANGUAGE_STANDARD = gnu99; 376 | GCC_DYNAMIC_NO_PIC = NO; 377 | GCC_NO_COMMON_BLOCKS = YES; 378 | GCC_OPTIMIZATION_LEVEL = 0; 379 | GCC_PREPROCESSOR_DEFINITIONS = ( 380 | "DEBUG=1", 381 | "$(inherited)", 382 | ); 383 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 384 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 385 | GCC_WARN_UNDECLARED_SELECTOR = YES; 386 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 387 | GCC_WARN_UNUSED_FUNCTION = YES; 388 | GCC_WARN_UNUSED_VARIABLE = YES; 389 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 390 | MTL_ENABLE_DEBUG_INFO = YES; 391 | ONLY_ACTIVE_ARCH = YES; 392 | SDKROOT = iphoneos; 393 | TARGETED_DEVICE_FAMILY = "1,2"; 394 | }; 395 | name = Debug; 396 | }; 397 | 00F668A71F1C8F79003F55F2 /* Release */ = { 398 | isa = XCBuildConfiguration; 399 | buildSettings = { 400 | ALWAYS_SEARCH_USER_PATHS = NO; 401 | CLANG_ANALYZER_NONNULL = YES; 402 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 403 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 404 | CLANG_CXX_LIBRARY = "libc++"; 405 | CLANG_ENABLE_MODULES = YES; 406 | CLANG_ENABLE_OBJC_ARC = YES; 407 | CLANG_WARN_BOOL_CONVERSION = YES; 408 | CLANG_WARN_CONSTANT_CONVERSION = YES; 409 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 410 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 411 | CLANG_WARN_EMPTY_BODY = YES; 412 | CLANG_WARN_ENUM_CONVERSION = YES; 413 | CLANG_WARN_INFINITE_RECURSION = YES; 414 | CLANG_WARN_INT_CONVERSION = YES; 415 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 416 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 417 | CLANG_WARN_UNREACHABLE_CODE = YES; 418 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 419 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 420 | COPY_PHASE_STRIP = NO; 421 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 422 | ENABLE_NS_ASSERTIONS = NO; 423 | ENABLE_STRICT_OBJC_MSGSEND = YES; 424 | GCC_C_LANGUAGE_STANDARD = gnu99; 425 | GCC_NO_COMMON_BLOCKS = YES; 426 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 427 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 428 | GCC_WARN_UNDECLARED_SELECTOR = YES; 429 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 430 | GCC_WARN_UNUSED_FUNCTION = YES; 431 | GCC_WARN_UNUSED_VARIABLE = YES; 432 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 433 | MTL_ENABLE_DEBUG_INFO = NO; 434 | SDKROOT = iphoneos; 435 | TARGETED_DEVICE_FAMILY = "1,2"; 436 | VALIDATE_PRODUCT = YES; 437 | }; 438 | name = Release; 439 | }; 440 | 00F668A91F1C8F79003F55F2 /* Debug */ = { 441 | isa = XCBuildConfiguration; 442 | buildSettings = { 443 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 444 | DEVELOPMENT_TEAM = ""; 445 | INFOPLIST_FILE = NNValidationCodeView/Info.plist; 446 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 447 | PRODUCT_BUNDLE_IDENTIFIER = liupengkun.NNValidationCodeView; 448 | PRODUCT_NAME = "$(TARGET_NAME)"; 449 | }; 450 | name = Debug; 451 | }; 452 | 00F668AA1F1C8F79003F55F2 /* Release */ = { 453 | isa = XCBuildConfiguration; 454 | buildSettings = { 455 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 456 | DEVELOPMENT_TEAM = ""; 457 | INFOPLIST_FILE = NNValidationCodeView/Info.plist; 458 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 459 | PRODUCT_BUNDLE_IDENTIFIER = liupengkun.NNValidationCodeView; 460 | PRODUCT_NAME = "$(TARGET_NAME)"; 461 | }; 462 | name = Release; 463 | }; 464 | 00F668AC1F1C8F79003F55F2 /* Debug */ = { 465 | isa = XCBuildConfiguration; 466 | buildSettings = { 467 | BUNDLE_LOADER = "$(TEST_HOST)"; 468 | INFOPLIST_FILE = NNValidationCodeViewTests/Info.plist; 469 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 470 | PRODUCT_BUNDLE_IDENTIFIER = LiuZhongNing.NNValidationCodeViewTests; 471 | PRODUCT_NAME = "$(TARGET_NAME)"; 472 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/NNValidationCodeView.app/NNValidationCodeView"; 473 | }; 474 | name = Debug; 475 | }; 476 | 00F668AD1F1C8F79003F55F2 /* Release */ = { 477 | isa = XCBuildConfiguration; 478 | buildSettings = { 479 | BUNDLE_LOADER = "$(TEST_HOST)"; 480 | INFOPLIST_FILE = NNValidationCodeViewTests/Info.plist; 481 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 482 | PRODUCT_BUNDLE_IDENTIFIER = LiuZhongNing.NNValidationCodeViewTests; 483 | PRODUCT_NAME = "$(TARGET_NAME)"; 484 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/NNValidationCodeView.app/NNValidationCodeView"; 485 | }; 486 | name = Release; 487 | }; 488 | 00F668AF1F1C8F79003F55F2 /* Debug */ = { 489 | isa = XCBuildConfiguration; 490 | buildSettings = { 491 | INFOPLIST_FILE = NNValidationCodeViewUITests/Info.plist; 492 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 493 | PRODUCT_BUNDLE_IDENTIFIER = LiuZhongNing.NNValidationCodeViewUITests; 494 | PRODUCT_NAME = "$(TARGET_NAME)"; 495 | TEST_TARGET_NAME = NNValidationCodeView; 496 | }; 497 | name = Debug; 498 | }; 499 | 00F668B01F1C8F79003F55F2 /* Release */ = { 500 | isa = XCBuildConfiguration; 501 | buildSettings = { 502 | INFOPLIST_FILE = NNValidationCodeViewUITests/Info.plist; 503 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 504 | PRODUCT_BUNDLE_IDENTIFIER = LiuZhongNing.NNValidationCodeViewUITests; 505 | PRODUCT_NAME = "$(TARGET_NAME)"; 506 | TEST_TARGET_NAME = NNValidationCodeView; 507 | }; 508 | name = Release; 509 | }; 510 | /* End XCBuildConfiguration section */ 511 | 512 | /* Begin XCConfigurationList section */ 513 | 00F668761F1C8F79003F55F2 /* Build configuration list for PBXProject "NNValidationCodeView" */ = { 514 | isa = XCConfigurationList; 515 | buildConfigurations = ( 516 | 00F668A61F1C8F79003F55F2 /* Debug */, 517 | 00F668A71F1C8F79003F55F2 /* Release */, 518 | ); 519 | defaultConfigurationIsVisible = 0; 520 | defaultConfigurationName = Release; 521 | }; 522 | 00F668A81F1C8F79003F55F2 /* Build configuration list for PBXNativeTarget "NNValidationCodeView" */ = { 523 | isa = XCConfigurationList; 524 | buildConfigurations = ( 525 | 00F668A91F1C8F79003F55F2 /* Debug */, 526 | 00F668AA1F1C8F79003F55F2 /* Release */, 527 | ); 528 | defaultConfigurationIsVisible = 0; 529 | defaultConfigurationName = Release; 530 | }; 531 | 00F668AB1F1C8F79003F55F2 /* Build configuration list for PBXNativeTarget "NNValidationCodeViewTests" */ = { 532 | isa = XCConfigurationList; 533 | buildConfigurations = ( 534 | 00F668AC1F1C8F79003F55F2 /* Debug */, 535 | 00F668AD1F1C8F79003F55F2 /* Release */, 536 | ); 537 | defaultConfigurationIsVisible = 0; 538 | defaultConfigurationName = Release; 539 | }; 540 | 00F668AE1F1C8F79003F55F2 /* Build configuration list for PBXNativeTarget "NNValidationCodeViewUITests" */ = { 541 | isa = XCConfigurationList; 542 | buildConfigurations = ( 543 | 00F668AF1F1C8F79003F55F2 /* Debug */, 544 | 00F668B01F1C8F79003F55F2 /* Release */, 545 | ); 546 | defaultConfigurationIsVisible = 0; 547 | defaultConfigurationName = Release; 548 | }; 549 | /* End XCConfigurationList section */ 550 | }; 551 | rootObject = 00F668731F1C8F79003F55F2 /* Project object */; 552 | } 553 | -------------------------------------------------------------------------------- /NNValidationCodeView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /NNValidationCodeView.xcodeproj/project.xcworkspace/xcuserdata/edz.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LiuPengKun1993/NNValidationCodeView/02c186e21b4f43e13151fadd6df410602b04b744/NNValidationCodeView.xcodeproj/project.xcworkspace/xcuserdata/edz.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /NNValidationCodeView.xcodeproj/project.xcworkspace/xcuserdata/yizhilu.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LiuPengKun1993/NNValidationCodeView/02c186e21b4f43e13151fadd6df410602b04b744/NNValidationCodeView.xcodeproj/project.xcworkspace/xcuserdata/yizhilu.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /NNValidationCodeView.xcodeproj/xcuserdata/edz.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /NNValidationCodeView.xcodeproj/xcuserdata/edz.xcuserdatad/xcschemes/NNValidationCodeView.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 43 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 74 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 95 | 101 | 102 | 103 | 104 | 106 | 107 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /NNValidationCodeView.xcodeproj/xcuserdata/edz.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | NNValidationCodeView.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 00F6687A1F1C8F79003F55F2 16 | 17 | primary 18 | 19 | 20 | 00F668931F1C8F79003F55F2 21 | 22 | primary 23 | 24 | 25 | 00F6689E1F1C8F79003F55F2 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /NNValidationCodeView.xcodeproj/xcuserdata/yizhilu.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | NNValidationCodeView.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /NNValidationCodeView/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // NNValidationCodeView 4 | // 5 | // Created by edz on 2017/7/17. 6 | // Copyright © 2017年 刘朋坤. 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 | -------------------------------------------------------------------------------- /NNValidationCodeView/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // NNValidationCodeView 4 | // 5 | // Created by edz on 2017/7/17. 6 | // Copyright © 2017年 刘朋坤. 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 | -------------------------------------------------------------------------------- /NNValidationCodeView/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 | } -------------------------------------------------------------------------------- /NNValidationCodeView/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 | -------------------------------------------------------------------------------- /NNValidationCodeView/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 | -------------------------------------------------------------------------------- /NNValidationCodeView/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 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /NNValidationCodeView/NNValidationCodeView/NNValidationCodeView.h: -------------------------------------------------------------------------------- 1 | // 2 | // NNValidationCodeView.h 3 | // NNValidationCodeView 4 | // 5 | // Created by edz on 2017/7/17. 6 | // Copyright © 2017年 刘朋坤. All rights reserved. 7 | // 8 | 9 | #import 10 | typedef void(^NNCodeDidChangeBlock)(NSString *codeString); 11 | 12 | @interface NNValidationCodeView : UIView 13 | 14 | - (instancetype)initWithFrame:(CGRect)frame andLabelCount:(NSInteger)labelCount andLabelDistance:(CGFloat)labelDistance; 15 | /// 回调的 block , 获取输入的数字 16 | @property (nonatomic, copy) NNCodeDidChangeBlock codeBlock; 17 | /// 默认颜色 不设置的话是黑色 18 | @property (nonatomic, strong) UIColor *defaultColor; 19 | /// 改变后的颜色 不设置的话是红色 20 | @property (nonatomic, strong) UIColor *changedColor; 21 | 22 | @end 23 | 24 | @interface NNTextField : UITextField 25 | 26 | @end 27 | 28 | -------------------------------------------------------------------------------- /NNValidationCodeView/NNValidationCodeView/NNValidationCodeView.m: -------------------------------------------------------------------------------- 1 | // 2 | // NNValidationCodeView.m 3 | // NNValidationCodeView 4 | // 5 | // Created by edz on 2017/7/17. 6 | // Copyright © 2017年 刘朋坤. All rights reserved. 7 | // 8 | 9 | #import "NNValidationCodeView.h" 10 | #define NNCodeViewHeight self.frame.size.height 11 | 12 | @interface NNValidationCodeView() 13 | 14 | /// 存放 label 的数组 15 | @property (nonatomic, strong) NSMutableArray *labelArr; 16 | /// label 的数量 17 | @property (nonatomic, assign) NSInteger labelCount; 18 | /// label 之间的距离 19 | @property (nonatomic, assign) CGFloat labelDistance; 20 | /// 输入文本框 21 | @property (nonatomic, strong) NNTextField *codeTextField; 22 | 23 | @end 24 | 25 | @implementation NNValidationCodeView 26 | 27 | - (instancetype)initWithFrame:(CGRect)frame andLabelCount:(NSInteger)labelCount andLabelDistance:(CGFloat)labelDistance { 28 | 29 | self = [super initWithFrame:frame]; 30 | if (self) { 31 | self.backgroundColor = [UIColor whiteColor]; 32 | self.labelCount = labelCount; 33 | self.labelDistance = labelDistance; 34 | self.changedColor = [UIColor redColor]; 35 | self.defaultColor = [UIColor blackColor]; 36 | [self setupViews]; 37 | } 38 | return self; 39 | } 40 | 41 | - (void)setupViews { 42 | CGFloat labelX; 43 | CGFloat labelY = 0; 44 | CGFloat labelWidth = self.codeTextField.frame.size.width / self.labelCount; 45 | CGFloat sideLength = labelWidth < NNCodeViewHeight ? labelWidth : NNCodeViewHeight; 46 | for (int i = 0; i < self.labelCount; i++) { 47 | if (i == 0) { 48 | labelX = 0; 49 | } else { 50 | labelX = i * (sideLength + self.labelDistance); 51 | } 52 | UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(labelX, labelY, sideLength, sideLength)]; 53 | [self addSubview:label]; 54 | label.textAlignment = NSTextAlignmentCenter; 55 | label.layer.borderColor = [UIColor blackColor].CGColor; 56 | label.layer.borderWidth = 1; 57 | label.layer.cornerRadius = sideLength / 2; 58 | [self.labelArr addObject:label]; 59 | } 60 | } 61 | 62 | - (void)textFieldDidChange:(UITextField *)textField { 63 | NSInteger i = textField.text.length; 64 | if (i == 0) { 65 | ((UILabel *)[self.labelArr objectAtIndex:0]).text = @""; 66 | ((UILabel *)[self.labelArr objectAtIndex:0]).layer.borderColor = _defaultColor.CGColor; 67 | } else { 68 | ((UILabel *)[self.labelArr objectAtIndex:i - 1]).text = [NSString stringWithFormat:@"%C", [textField.text characterAtIndex:i - 1]]; 69 | ((UILabel *)[self.labelArr objectAtIndex:i - 1]).layer.borderColor = _changedColor.CGColor; 70 | ((UILabel *)[self.labelArr objectAtIndex:i - 1]).textColor = _changedColor; 71 | if (self.labelCount > i) { 72 | ((UILabel *)[self.labelArr objectAtIndex:i]).text = @""; 73 | ((UILabel *)[self.labelArr objectAtIndex:i]).layer.borderColor = _defaultColor.CGColor; 74 | } 75 | } 76 | if (self.codeBlock) { 77 | self.codeBlock(textField.text); 78 | } 79 | } 80 | 81 | #pragma mark - UITextFieldDelegate 82 | - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { 83 | if ([string isEqualToString:@"\n"]) { 84 | [textField resignFirstResponder]; 85 | return NO; 86 | } else if (string.length == 0) { 87 | return YES; 88 | } else if (textField.text.length >= self.labelCount) { 89 | return NO; 90 | } else { 91 | return YES; 92 | } 93 | } 94 | 95 | #pragma mark - 懒加载 96 | - (NNTextField *)codeTextField { 97 | if (!_codeTextField) { 98 | _codeTextField = [[NNTextField alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, NNCodeViewHeight)]; 99 | _codeTextField.backgroundColor = [UIColor clearColor]; 100 | _codeTextField.textColor = [UIColor clearColor]; 101 | _codeTextField.tintColor = [UIColor clearColor]; 102 | _codeTextField.delegate = self; 103 | _codeTextField.autocapitalizationType = UITextAutocapitalizationTypeNone; 104 | _codeTextField.keyboardType = UIKeyboardTypeNumberPad; 105 | _codeTextField.layer.borderColor = [[UIColor grayColor] CGColor]; 106 | [_codeTextField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged]; 107 | [self addSubview:_codeTextField]; 108 | } 109 | return _codeTextField; 110 | } 111 | 112 | #pragma mark - 懒加载 113 | - (NSMutableArray *)labelArr { 114 | if (!_labelArr) { 115 | _labelArr = [NSMutableArray array]; 116 | } 117 | return _labelArr; 118 | } 119 | 120 | @end 121 | 122 | 123 | @implementation NNTextField 124 | 125 | /// 重写 UITextFiled 子类, 解决长按复制粘贴的问题 126 | - (BOOL)canPerformAction:(SEL)action withSender:(id)sender { 127 | UIMenuController *menuController = [UIMenuController sharedMenuController]; 128 | if (menuController) { 129 | [UIMenuController sharedMenuController].menuVisible = NO; 130 | } 131 | return NO; 132 | } 133 | 134 | @end 135 | -------------------------------------------------------------------------------- /NNValidationCodeView/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // NNValidationCodeView 4 | // 5 | // Created by edz on 2017/7/17. 6 | // Copyright © 2017年 刘朋坤. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /NNValidationCodeView/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // NNValidationCodeView 4 | // 5 | // Created by edz on 2017/7/17. 6 | // Copyright © 2017年 刘朋坤. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "NNValidationCodeView.h" 11 | @interface ViewController () 12 | 13 | @end 14 | 15 | @implementation ViewController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | NNValidationCodeView *view = [[NNValidationCodeView alloc] initWithFrame:CGRectMake(60, 100, 300, 40) andLabelCount:6 andLabelDistance:5]; 20 | // NNValidationCodeView *view = [[NNValidationCodeView alloc] initWithFrame:CGRectMake(80, 100, 300, 45) andLabelCount:4 andLabelDistance:10]; 21 | [self.view addSubview:view]; 22 | // view.changedColor = [UIColor yellowColor]; 23 | view.codeBlock = ^(NSString *codeString) { 24 | NSLog(@"验证码:%@", codeString); 25 | }; 26 | } 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /NNValidationCodeView/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // NNValidationCodeView 4 | // 5 | // Created by edz on 2017/7/17. 6 | // Copyright © 2017年 刘朋坤. 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 | -------------------------------------------------------------------------------- /NNValidationCodeViewTests/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 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /NNValidationCodeViewTests/NNValidationCodeViewTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // NNValidationCodeViewTests.m 3 | // NNValidationCodeViewTests 4 | // 5 | // Created by edz on 2017/7/17. 6 | // Copyright © 2017年 刘朋坤. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NNValidationCodeViewTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation NNValidationCodeViewTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /NNValidationCodeViewUITests/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 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /NNValidationCodeViewUITests/NNValidationCodeViewUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // NNValidationCodeViewUITests.m 3 | // NNValidationCodeViewUITests 4 | // 5 | // Created by edz on 2017/7/17. 6 | // Copyright © 2017年 刘朋坤. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NNValidationCodeViewUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation NNValidationCodeViewUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NNValidationCodeView 2 | 3 | 封装的圆形验证码输入框,输入框的大小、数量、颜色、距离等都可以自行设定! 4 | 5 | 6 | 只需几行代码即可: 7 | 8 | ``` 9 | NNValidationCodeView *view = [[NNValidationCodeView alloc] initWithFrame:CGRectMake(80, 100, 300, 45) andLabelCount:4 andLabelDistance:10]; 10 | [self.view addSubview:view]; 11 | view.changedColor = [UIColor yellowColor]; 12 | view.codeBlock = ^(NSString *codeString) { 13 | NSLog(@"验证码:%@", codeString); 14 | }; 15 | 16 | ``` 17 | 18 | ![演示图1](https://github.com/liuzhongning/NNValidationCodeView/blob/master/DemoFigure/111.gif) 19 | 20 | ![演示图2](https://github.com/liuzhongning/NNValidationCodeView/blob/master/DemoFigure/222.gif) 21 | 22 | 23 | ### License 24 | 25 | This repositorie is released under the under [MIT License](https://github.com/liuzhongning/NNValidationCodeView/blob/master/LICENSE) 26 | --------------------------------------------------------------------------------