├── LICENSE ├── README.md ├── WMZCode.podspec ├── WMZCode.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ └── xcuserdata │ │ └── wmz.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ ├── apple.xcuserdatad │ └── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ └── wmz.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── WMZCode ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ ├── A.imageset │ │ ├── A.png │ │ └── Contents.json │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── B.imageset │ │ ├── B.png │ │ └── Contents.json │ ├── Contents.json │ ├── SliderBtn.imageset │ │ ├── A60FD1B7CBF08631A978DC3E57B4F221.png │ │ └── Contents.json │ └── refresh.imageset │ │ ├── Contents.json │ │ └── refresh.png ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── ViewController.h ├── ViewController.m ├── WMZCode │ ├── WMZCodeView.h │ └── WMZCodeView.m └── main.m ├── WMZCodeTests ├── Info.plist └── WMZCodeTests.m └── WMZCodeUITests ├── Info.plist └── WMZCodeUITests.m /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 WMZ 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WMZCode 2 | 3 | pod 'WMZCode', '~> 1.0.0' 4 | 5 | ## 在使用cocoapods安装时,请先执行 pod search WMZCode,如果搜索不到,请执行pod setup命令。 6 | 7 | 效果图 8 | 9 | ![Untitled.gif](https://upload-images.jianshu.io/upload_images/9163368-02e0387793a05194.gif?imageMogr2/auto-orient/strip) 10 | 11 | 四个枚举 12 | ``` 13 | /* 14 | * CodeType type 15 | */ 16 | typedef NS_ENUM(NSInteger, CodeType) { 17 | CodeTypeImage = 0, // DefaultImage 18 | CodeTypeLabel, // Label 19 | CodeTypeNineLabel, // NineLabel 20 | CodeTypeSlider // Slider 21 | }; 22 | ``` 23 | 24 | 调用 25 | ``` 26 | WMZCodeView *codeView = [[WMZCodeView shareInstance] addCodeViewWithType:CodeTypeImage withImageName:@"A" witgFrame:CGRectMake(0, 50, 300, 50) withBlock:^(BOOL success) { 27 | if (success) { 28 | NSLog(@"成功"); 29 | } 30 | }]; 31 | [superView addSubview: codeView] ; 32 | ``` 33 | -------------------------------------------------------------------------------- /WMZCode.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | 3 | s.name = "WMZCode" 4 | s.version = "1.0.2" 5 | s.license = "Copyright (c) 2018年 WMZ. All rights reserved." 6 | s.summary = "滑块验证" 7 | s.description = <<-DESC 8 | 四种验证 9 | DESC 10 | s.homepage = "https://github.com/wwmz/WMZCode" 11 | s.license = {:type => "MIT", :file => "LICENSE" } 12 | s.author = { "wmz" => "925457662@qq.com" } 13 | s.platform = :ios 14 | s.source = { :git => "https://github.com/wwmz/WMZCode.git",:tag => s.version.to_s} 15 | s.source_files = "WMZCode/WMZCode/**/*.{h,m}" 16 | s.requires_arc = true 17 | end 18 | -------------------------------------------------------------------------------- /WMZCode.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 18AB468821C37B6D0006B044 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 18AB468721C37B6D0006B044 /* AppDelegate.m */; }; 11 | 18AB468B21C37B6D0006B044 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 18AB468A21C37B6D0006B044 /* ViewController.m */; }; 12 | 18AB468E21C37B6D0006B044 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 18AB468C21C37B6D0006B044 /* Main.storyboard */; }; 13 | 18AB469021C37B750006B044 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 18AB468F21C37B750006B044 /* Assets.xcassets */; }; 14 | 18AB469321C37B750006B044 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 18AB469121C37B750006B044 /* LaunchScreen.storyboard */; }; 15 | 18AB469621C37B750006B044 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 18AB469521C37B750006B044 /* main.m */; }; 16 | 18AB46A021C37B750006B044 /* WMZCodeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 18AB469F21C37B750006B044 /* WMZCodeTests.m */; }; 17 | 18AB46AB21C37B750006B044 /* WMZCodeUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 18AB46AA21C37B750006B044 /* WMZCodeUITests.m */; }; 18 | 18AB46C121C390C30006B044 /* WMZCodeView.m in Sources */ = {isa = PBXBuildFile; fileRef = 18AB46C021C390C30006B044 /* WMZCodeView.m */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXContainerItemProxy section */ 22 | 18AB469C21C37B750006B044 /* PBXContainerItemProxy */ = { 23 | isa = PBXContainerItemProxy; 24 | containerPortal = 18AB467B21C37B6D0006B044 /* Project object */; 25 | proxyType = 1; 26 | remoteGlobalIDString = 18AB468221C37B6D0006B044; 27 | remoteInfo = WMZCode; 28 | }; 29 | 18AB46A721C37B750006B044 /* PBXContainerItemProxy */ = { 30 | isa = PBXContainerItemProxy; 31 | containerPortal = 18AB467B21C37B6D0006B044 /* Project object */; 32 | proxyType = 1; 33 | remoteGlobalIDString = 18AB468221C37B6D0006B044; 34 | remoteInfo = WMZCode; 35 | }; 36 | /* End PBXContainerItemProxy section */ 37 | 38 | /* Begin PBXFileReference section */ 39 | 18AB468321C37B6D0006B044 /* WMZCode.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = WMZCode.app; sourceTree = BUILT_PRODUCTS_DIR; }; 40 | 18AB468621C37B6D0006B044 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 41 | 18AB468721C37B6D0006B044 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 42 | 18AB468921C37B6D0006B044 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 43 | 18AB468A21C37B6D0006B044 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 44 | 18AB468D21C37B6D0006B044 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 45 | 18AB468F21C37B750006B044 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 46 | 18AB469221C37B750006B044 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 47 | 18AB469421C37B750006B044 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 48 | 18AB469521C37B750006B044 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 49 | 18AB469B21C37B750006B044 /* WMZCodeTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = WMZCodeTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 50 | 18AB469F21C37B750006B044 /* WMZCodeTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WMZCodeTests.m; sourceTree = ""; }; 51 | 18AB46A121C37B750006B044 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 52 | 18AB46A621C37B750006B044 /* WMZCodeUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = WMZCodeUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 53 | 18AB46AA21C37B750006B044 /* WMZCodeUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WMZCodeUITests.m; sourceTree = ""; }; 54 | 18AB46AC21C37B750006B044 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 55 | 18AB46BF21C390C30006B044 /* WMZCodeView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WMZCodeView.h; sourceTree = ""; }; 56 | 18AB46C021C390C30006B044 /* WMZCodeView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WMZCodeView.m; sourceTree = ""; }; 57 | /* End PBXFileReference section */ 58 | 59 | /* Begin PBXFrameworksBuildPhase section */ 60 | 18AB468021C37B6D0006B044 /* Frameworks */ = { 61 | isa = PBXFrameworksBuildPhase; 62 | buildActionMask = 2147483647; 63 | files = ( 64 | ); 65 | runOnlyForDeploymentPostprocessing = 0; 66 | }; 67 | 18AB469821C37B750006B044 /* Frameworks */ = { 68 | isa = PBXFrameworksBuildPhase; 69 | buildActionMask = 2147483647; 70 | files = ( 71 | ); 72 | runOnlyForDeploymentPostprocessing = 0; 73 | }; 74 | 18AB46A321C37B750006B044 /* Frameworks */ = { 75 | isa = PBXFrameworksBuildPhase; 76 | buildActionMask = 2147483647; 77 | files = ( 78 | ); 79 | runOnlyForDeploymentPostprocessing = 0; 80 | }; 81 | /* End PBXFrameworksBuildPhase section */ 82 | 83 | /* Begin PBXGroup section */ 84 | 18AB467A21C37B6D0006B044 = { 85 | isa = PBXGroup; 86 | children = ( 87 | 18AB468521C37B6D0006B044 /* WMZCode */, 88 | 18AB469E21C37B750006B044 /* WMZCodeTests */, 89 | 18AB46A921C37B750006B044 /* WMZCodeUITests */, 90 | 18AB468421C37B6D0006B044 /* Products */, 91 | ); 92 | sourceTree = ""; 93 | }; 94 | 18AB468421C37B6D0006B044 /* Products */ = { 95 | isa = PBXGroup; 96 | children = ( 97 | 18AB468321C37B6D0006B044 /* WMZCode.app */, 98 | 18AB469B21C37B750006B044 /* WMZCodeTests.xctest */, 99 | 18AB46A621C37B750006B044 /* WMZCodeUITests.xctest */, 100 | ); 101 | name = Products; 102 | sourceTree = ""; 103 | }; 104 | 18AB468521C37B6D0006B044 /* WMZCode */ = { 105 | isa = PBXGroup; 106 | children = ( 107 | 18AB46B821C37BCB0006B044 /* WMZCode */, 108 | 18AB468621C37B6D0006B044 /* AppDelegate.h */, 109 | 18AB468721C37B6D0006B044 /* AppDelegate.m */, 110 | 18AB468921C37B6D0006B044 /* ViewController.h */, 111 | 18AB468A21C37B6D0006B044 /* ViewController.m */, 112 | 18AB468C21C37B6D0006B044 /* Main.storyboard */, 113 | 18AB468F21C37B750006B044 /* Assets.xcassets */, 114 | 18AB469121C37B750006B044 /* LaunchScreen.storyboard */, 115 | 18AB469421C37B750006B044 /* Info.plist */, 116 | 18AB469521C37B750006B044 /* main.m */, 117 | ); 118 | path = WMZCode; 119 | sourceTree = ""; 120 | }; 121 | 18AB469E21C37B750006B044 /* WMZCodeTests */ = { 122 | isa = PBXGroup; 123 | children = ( 124 | 18AB469F21C37B750006B044 /* WMZCodeTests.m */, 125 | 18AB46A121C37B750006B044 /* Info.plist */, 126 | ); 127 | path = WMZCodeTests; 128 | sourceTree = ""; 129 | }; 130 | 18AB46A921C37B750006B044 /* WMZCodeUITests */ = { 131 | isa = PBXGroup; 132 | children = ( 133 | 18AB46AA21C37B750006B044 /* WMZCodeUITests.m */, 134 | 18AB46AC21C37B750006B044 /* Info.plist */, 135 | ); 136 | path = WMZCodeUITests; 137 | sourceTree = ""; 138 | }; 139 | 18AB46B821C37BCB0006B044 /* WMZCode */ = { 140 | isa = PBXGroup; 141 | children = ( 142 | 18AB46BF21C390C30006B044 /* WMZCodeView.h */, 143 | 18AB46C021C390C30006B044 /* WMZCodeView.m */, 144 | ); 145 | path = WMZCode; 146 | sourceTree = ""; 147 | }; 148 | /* End PBXGroup section */ 149 | 150 | /* Begin PBXNativeTarget section */ 151 | 18AB468221C37B6D0006B044 /* WMZCode */ = { 152 | isa = PBXNativeTarget; 153 | buildConfigurationList = 18AB46AF21C37B750006B044 /* Build configuration list for PBXNativeTarget "WMZCode" */; 154 | buildPhases = ( 155 | 18AB467F21C37B6D0006B044 /* Sources */, 156 | 18AB468021C37B6D0006B044 /* Frameworks */, 157 | 18AB468121C37B6D0006B044 /* Resources */, 158 | ); 159 | buildRules = ( 160 | ); 161 | dependencies = ( 162 | ); 163 | name = WMZCode; 164 | productName = WMZCode; 165 | productReference = 18AB468321C37B6D0006B044 /* WMZCode.app */; 166 | productType = "com.apple.product-type.application"; 167 | }; 168 | 18AB469A21C37B750006B044 /* WMZCodeTests */ = { 169 | isa = PBXNativeTarget; 170 | buildConfigurationList = 18AB46B221C37B750006B044 /* Build configuration list for PBXNativeTarget "WMZCodeTests" */; 171 | buildPhases = ( 172 | 18AB469721C37B750006B044 /* Sources */, 173 | 18AB469821C37B750006B044 /* Frameworks */, 174 | 18AB469921C37B750006B044 /* Resources */, 175 | ); 176 | buildRules = ( 177 | ); 178 | dependencies = ( 179 | 18AB469D21C37B750006B044 /* PBXTargetDependency */, 180 | ); 181 | name = WMZCodeTests; 182 | productName = WMZCodeTests; 183 | productReference = 18AB469B21C37B750006B044 /* WMZCodeTests.xctest */; 184 | productType = "com.apple.product-type.bundle.unit-test"; 185 | }; 186 | 18AB46A521C37B750006B044 /* WMZCodeUITests */ = { 187 | isa = PBXNativeTarget; 188 | buildConfigurationList = 18AB46B521C37B750006B044 /* Build configuration list for PBXNativeTarget "WMZCodeUITests" */; 189 | buildPhases = ( 190 | 18AB46A221C37B750006B044 /* Sources */, 191 | 18AB46A321C37B750006B044 /* Frameworks */, 192 | 18AB46A421C37B750006B044 /* Resources */, 193 | ); 194 | buildRules = ( 195 | ); 196 | dependencies = ( 197 | 18AB46A821C37B750006B044 /* PBXTargetDependency */, 198 | ); 199 | name = WMZCodeUITests; 200 | productName = WMZCodeUITests; 201 | productReference = 18AB46A621C37B750006B044 /* WMZCodeUITests.xctest */; 202 | productType = "com.apple.product-type.bundle.ui-testing"; 203 | }; 204 | /* End PBXNativeTarget section */ 205 | 206 | /* Begin PBXProject section */ 207 | 18AB467B21C37B6D0006B044 /* Project object */ = { 208 | isa = PBXProject; 209 | attributes = { 210 | LastUpgradeCheck = 1000; 211 | ORGANIZATIONNAME = wmz; 212 | TargetAttributes = { 213 | 18AB468221C37B6D0006B044 = { 214 | CreatedOnToolsVersion = 10.0; 215 | }; 216 | 18AB469A21C37B750006B044 = { 217 | CreatedOnToolsVersion = 10.0; 218 | TestTargetID = 18AB468221C37B6D0006B044; 219 | }; 220 | 18AB46A521C37B750006B044 = { 221 | CreatedOnToolsVersion = 10.0; 222 | TestTargetID = 18AB468221C37B6D0006B044; 223 | }; 224 | }; 225 | }; 226 | buildConfigurationList = 18AB467E21C37B6D0006B044 /* Build configuration list for PBXProject "WMZCode" */; 227 | compatibilityVersion = "Xcode 9.3"; 228 | developmentRegion = en; 229 | hasScannedForEncodings = 0; 230 | knownRegions = ( 231 | en, 232 | Base, 233 | ); 234 | mainGroup = 18AB467A21C37B6D0006B044; 235 | productRefGroup = 18AB468421C37B6D0006B044 /* Products */; 236 | projectDirPath = ""; 237 | projectRoot = ""; 238 | targets = ( 239 | 18AB468221C37B6D0006B044 /* WMZCode */, 240 | 18AB469A21C37B750006B044 /* WMZCodeTests */, 241 | 18AB46A521C37B750006B044 /* WMZCodeUITests */, 242 | ); 243 | }; 244 | /* End PBXProject section */ 245 | 246 | /* Begin PBXResourcesBuildPhase section */ 247 | 18AB468121C37B6D0006B044 /* Resources */ = { 248 | isa = PBXResourcesBuildPhase; 249 | buildActionMask = 2147483647; 250 | files = ( 251 | 18AB469321C37B750006B044 /* LaunchScreen.storyboard in Resources */, 252 | 18AB469021C37B750006B044 /* Assets.xcassets in Resources */, 253 | 18AB468E21C37B6D0006B044 /* Main.storyboard in Resources */, 254 | ); 255 | runOnlyForDeploymentPostprocessing = 0; 256 | }; 257 | 18AB469921C37B750006B044 /* Resources */ = { 258 | isa = PBXResourcesBuildPhase; 259 | buildActionMask = 2147483647; 260 | files = ( 261 | ); 262 | runOnlyForDeploymentPostprocessing = 0; 263 | }; 264 | 18AB46A421C37B750006B044 /* Resources */ = { 265 | isa = PBXResourcesBuildPhase; 266 | buildActionMask = 2147483647; 267 | files = ( 268 | ); 269 | runOnlyForDeploymentPostprocessing = 0; 270 | }; 271 | /* End PBXResourcesBuildPhase section */ 272 | 273 | /* Begin PBXSourcesBuildPhase section */ 274 | 18AB467F21C37B6D0006B044 /* Sources */ = { 275 | isa = PBXSourcesBuildPhase; 276 | buildActionMask = 2147483647; 277 | files = ( 278 | 18AB468B21C37B6D0006B044 /* ViewController.m in Sources */, 279 | 18AB469621C37B750006B044 /* main.m in Sources */, 280 | 18AB46C121C390C30006B044 /* WMZCodeView.m in Sources */, 281 | 18AB468821C37B6D0006B044 /* AppDelegate.m in Sources */, 282 | ); 283 | runOnlyForDeploymentPostprocessing = 0; 284 | }; 285 | 18AB469721C37B750006B044 /* Sources */ = { 286 | isa = PBXSourcesBuildPhase; 287 | buildActionMask = 2147483647; 288 | files = ( 289 | 18AB46A021C37B750006B044 /* WMZCodeTests.m in Sources */, 290 | ); 291 | runOnlyForDeploymentPostprocessing = 0; 292 | }; 293 | 18AB46A221C37B750006B044 /* Sources */ = { 294 | isa = PBXSourcesBuildPhase; 295 | buildActionMask = 2147483647; 296 | files = ( 297 | 18AB46AB21C37B750006B044 /* WMZCodeUITests.m in Sources */, 298 | ); 299 | runOnlyForDeploymentPostprocessing = 0; 300 | }; 301 | /* End PBXSourcesBuildPhase section */ 302 | 303 | /* Begin PBXTargetDependency section */ 304 | 18AB469D21C37B750006B044 /* PBXTargetDependency */ = { 305 | isa = PBXTargetDependency; 306 | target = 18AB468221C37B6D0006B044 /* WMZCode */; 307 | targetProxy = 18AB469C21C37B750006B044 /* PBXContainerItemProxy */; 308 | }; 309 | 18AB46A821C37B750006B044 /* PBXTargetDependency */ = { 310 | isa = PBXTargetDependency; 311 | target = 18AB468221C37B6D0006B044 /* WMZCode */; 312 | targetProxy = 18AB46A721C37B750006B044 /* PBXContainerItemProxy */; 313 | }; 314 | /* End PBXTargetDependency section */ 315 | 316 | /* Begin PBXVariantGroup section */ 317 | 18AB468C21C37B6D0006B044 /* Main.storyboard */ = { 318 | isa = PBXVariantGroup; 319 | children = ( 320 | 18AB468D21C37B6D0006B044 /* Base */, 321 | ); 322 | name = Main.storyboard; 323 | sourceTree = ""; 324 | }; 325 | 18AB469121C37B750006B044 /* LaunchScreen.storyboard */ = { 326 | isa = PBXVariantGroup; 327 | children = ( 328 | 18AB469221C37B750006B044 /* Base */, 329 | ); 330 | name = LaunchScreen.storyboard; 331 | sourceTree = ""; 332 | }; 333 | /* End PBXVariantGroup section */ 334 | 335 | /* Begin XCBuildConfiguration section */ 336 | 18AB46AD21C37B750006B044 /* Debug */ = { 337 | isa = XCBuildConfiguration; 338 | buildSettings = { 339 | ALWAYS_SEARCH_USER_PATHS = NO; 340 | CLANG_ANALYZER_NONNULL = YES; 341 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 342 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 343 | CLANG_CXX_LIBRARY = "libc++"; 344 | CLANG_ENABLE_MODULES = YES; 345 | CLANG_ENABLE_OBJC_ARC = YES; 346 | CLANG_ENABLE_OBJC_WEAK = YES; 347 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 348 | CLANG_WARN_BOOL_CONVERSION = YES; 349 | CLANG_WARN_COMMA = YES; 350 | CLANG_WARN_CONSTANT_CONVERSION = YES; 351 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 352 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 353 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 354 | CLANG_WARN_EMPTY_BODY = YES; 355 | CLANG_WARN_ENUM_CONVERSION = YES; 356 | CLANG_WARN_INFINITE_RECURSION = YES; 357 | CLANG_WARN_INT_CONVERSION = YES; 358 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 359 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 360 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 361 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 362 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 363 | CLANG_WARN_STRICT_PROTOTYPES = YES; 364 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 365 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 366 | CLANG_WARN_UNREACHABLE_CODE = YES; 367 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 368 | CODE_SIGN_IDENTITY = "iPhone Developer"; 369 | COPY_PHASE_STRIP = NO; 370 | DEBUG_INFORMATION_FORMAT = dwarf; 371 | ENABLE_STRICT_OBJC_MSGSEND = YES; 372 | ENABLE_TESTABILITY = YES; 373 | GCC_C_LANGUAGE_STANDARD = gnu11; 374 | GCC_DYNAMIC_NO_PIC = NO; 375 | GCC_NO_COMMON_BLOCKS = YES; 376 | GCC_OPTIMIZATION_LEVEL = 0; 377 | GCC_PREPROCESSOR_DEFINITIONS = ( 378 | "DEBUG=1", 379 | "$(inherited)", 380 | ); 381 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 382 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 383 | GCC_WARN_UNDECLARED_SELECTOR = YES; 384 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 385 | GCC_WARN_UNUSED_FUNCTION = YES; 386 | GCC_WARN_UNUSED_VARIABLE = YES; 387 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 388 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 389 | MTL_FAST_MATH = YES; 390 | ONLY_ACTIVE_ARCH = YES; 391 | SDKROOT = iphoneos; 392 | }; 393 | name = Debug; 394 | }; 395 | 18AB46AE21C37B750006B044 /* Release */ = { 396 | isa = XCBuildConfiguration; 397 | buildSettings = { 398 | ALWAYS_SEARCH_USER_PATHS = NO; 399 | CLANG_ANALYZER_NONNULL = YES; 400 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 401 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 402 | CLANG_CXX_LIBRARY = "libc++"; 403 | CLANG_ENABLE_MODULES = YES; 404 | CLANG_ENABLE_OBJC_ARC = YES; 405 | CLANG_ENABLE_OBJC_WEAK = YES; 406 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 407 | CLANG_WARN_BOOL_CONVERSION = YES; 408 | CLANG_WARN_COMMA = YES; 409 | CLANG_WARN_CONSTANT_CONVERSION = YES; 410 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 411 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 412 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 413 | CLANG_WARN_EMPTY_BODY = YES; 414 | CLANG_WARN_ENUM_CONVERSION = YES; 415 | CLANG_WARN_INFINITE_RECURSION = YES; 416 | CLANG_WARN_INT_CONVERSION = YES; 417 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 418 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 419 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 420 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 421 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 422 | CLANG_WARN_STRICT_PROTOTYPES = YES; 423 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 424 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 425 | CLANG_WARN_UNREACHABLE_CODE = YES; 426 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 427 | CODE_SIGN_IDENTITY = "iPhone Developer"; 428 | COPY_PHASE_STRIP = NO; 429 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 430 | ENABLE_NS_ASSERTIONS = NO; 431 | ENABLE_STRICT_OBJC_MSGSEND = YES; 432 | GCC_C_LANGUAGE_STANDARD = gnu11; 433 | GCC_NO_COMMON_BLOCKS = YES; 434 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 435 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 436 | GCC_WARN_UNDECLARED_SELECTOR = YES; 437 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 438 | GCC_WARN_UNUSED_FUNCTION = YES; 439 | GCC_WARN_UNUSED_VARIABLE = YES; 440 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 441 | MTL_ENABLE_DEBUG_INFO = NO; 442 | MTL_FAST_MATH = YES; 443 | SDKROOT = iphoneos; 444 | VALIDATE_PRODUCT = YES; 445 | }; 446 | name = Release; 447 | }; 448 | 18AB46B021C37B750006B044 /* Debug */ = { 449 | isa = XCBuildConfiguration; 450 | buildSettings = { 451 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 452 | CODE_SIGN_STYLE = Automatic; 453 | DEVELOPMENT_TEAM = HR6T4LQD9T; 454 | INFOPLIST_FILE = WMZCode/Info.plist; 455 | LD_RUNPATH_SEARCH_PATHS = ( 456 | "$(inherited)", 457 | "@executable_path/Frameworks", 458 | ); 459 | PRODUCT_BUNDLE_IDENTIFIER = com.WMZCode; 460 | PRODUCT_NAME = "$(TARGET_NAME)"; 461 | TARGETED_DEVICE_FAMILY = "1,2"; 462 | }; 463 | name = Debug; 464 | }; 465 | 18AB46B121C37B750006B044 /* Release */ = { 466 | isa = XCBuildConfiguration; 467 | buildSettings = { 468 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 469 | CODE_SIGN_STYLE = Automatic; 470 | DEVELOPMENT_TEAM = HR6T4LQD9T; 471 | INFOPLIST_FILE = WMZCode/Info.plist; 472 | LD_RUNPATH_SEARCH_PATHS = ( 473 | "$(inherited)", 474 | "@executable_path/Frameworks", 475 | ); 476 | PRODUCT_BUNDLE_IDENTIFIER = com.WMZCode; 477 | PRODUCT_NAME = "$(TARGET_NAME)"; 478 | TARGETED_DEVICE_FAMILY = "1,2"; 479 | }; 480 | name = Release; 481 | }; 482 | 18AB46B321C37B750006B044 /* Debug */ = { 483 | isa = XCBuildConfiguration; 484 | buildSettings = { 485 | BUNDLE_LOADER = "$(TEST_HOST)"; 486 | CODE_SIGN_STYLE = Automatic; 487 | DEVELOPMENT_TEAM = HR6T4LQD9T; 488 | INFOPLIST_FILE = WMZCodeTests/Info.plist; 489 | LD_RUNPATH_SEARCH_PATHS = ( 490 | "$(inherited)", 491 | "@executable_path/Frameworks", 492 | "@loader_path/Frameworks", 493 | ); 494 | PRODUCT_BUNDLE_IDENTIFIER = com.WMZCodeTests; 495 | PRODUCT_NAME = "$(TARGET_NAME)"; 496 | TARGETED_DEVICE_FAMILY = "1,2"; 497 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WMZCode.app/WMZCode"; 498 | }; 499 | name = Debug; 500 | }; 501 | 18AB46B421C37B750006B044 /* Release */ = { 502 | isa = XCBuildConfiguration; 503 | buildSettings = { 504 | BUNDLE_LOADER = "$(TEST_HOST)"; 505 | CODE_SIGN_STYLE = Automatic; 506 | DEVELOPMENT_TEAM = HR6T4LQD9T; 507 | INFOPLIST_FILE = WMZCodeTests/Info.plist; 508 | LD_RUNPATH_SEARCH_PATHS = ( 509 | "$(inherited)", 510 | "@executable_path/Frameworks", 511 | "@loader_path/Frameworks", 512 | ); 513 | PRODUCT_BUNDLE_IDENTIFIER = com.WMZCodeTests; 514 | PRODUCT_NAME = "$(TARGET_NAME)"; 515 | TARGETED_DEVICE_FAMILY = "1,2"; 516 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WMZCode.app/WMZCode"; 517 | }; 518 | name = Release; 519 | }; 520 | 18AB46B621C37B750006B044 /* Debug */ = { 521 | isa = XCBuildConfiguration; 522 | buildSettings = { 523 | CODE_SIGN_STYLE = Automatic; 524 | DEVELOPMENT_TEAM = HR6T4LQD9T; 525 | INFOPLIST_FILE = WMZCodeUITests/Info.plist; 526 | LD_RUNPATH_SEARCH_PATHS = ( 527 | "$(inherited)", 528 | "@executable_path/Frameworks", 529 | "@loader_path/Frameworks", 530 | ); 531 | PRODUCT_BUNDLE_IDENTIFIER = com.WMZCodeUITests; 532 | PRODUCT_NAME = "$(TARGET_NAME)"; 533 | TARGETED_DEVICE_FAMILY = "1,2"; 534 | TEST_TARGET_NAME = WMZCode; 535 | }; 536 | name = Debug; 537 | }; 538 | 18AB46B721C37B750006B044 /* Release */ = { 539 | isa = XCBuildConfiguration; 540 | buildSettings = { 541 | CODE_SIGN_STYLE = Automatic; 542 | DEVELOPMENT_TEAM = HR6T4LQD9T; 543 | INFOPLIST_FILE = WMZCodeUITests/Info.plist; 544 | LD_RUNPATH_SEARCH_PATHS = ( 545 | "$(inherited)", 546 | "@executable_path/Frameworks", 547 | "@loader_path/Frameworks", 548 | ); 549 | PRODUCT_BUNDLE_IDENTIFIER = com.WMZCodeUITests; 550 | PRODUCT_NAME = "$(TARGET_NAME)"; 551 | TARGETED_DEVICE_FAMILY = "1,2"; 552 | TEST_TARGET_NAME = WMZCode; 553 | }; 554 | name = Release; 555 | }; 556 | /* End XCBuildConfiguration section */ 557 | 558 | /* Begin XCConfigurationList section */ 559 | 18AB467E21C37B6D0006B044 /* Build configuration list for PBXProject "WMZCode" */ = { 560 | isa = XCConfigurationList; 561 | buildConfigurations = ( 562 | 18AB46AD21C37B750006B044 /* Debug */, 563 | 18AB46AE21C37B750006B044 /* Release */, 564 | ); 565 | defaultConfigurationIsVisible = 0; 566 | defaultConfigurationName = Release; 567 | }; 568 | 18AB46AF21C37B750006B044 /* Build configuration list for PBXNativeTarget "WMZCode" */ = { 569 | isa = XCConfigurationList; 570 | buildConfigurations = ( 571 | 18AB46B021C37B750006B044 /* Debug */, 572 | 18AB46B121C37B750006B044 /* Release */, 573 | ); 574 | defaultConfigurationIsVisible = 0; 575 | defaultConfigurationName = Release; 576 | }; 577 | 18AB46B221C37B750006B044 /* Build configuration list for PBXNativeTarget "WMZCodeTests" */ = { 578 | isa = XCConfigurationList; 579 | buildConfigurations = ( 580 | 18AB46B321C37B750006B044 /* Debug */, 581 | 18AB46B421C37B750006B044 /* Release */, 582 | ); 583 | defaultConfigurationIsVisible = 0; 584 | defaultConfigurationName = Release; 585 | }; 586 | 18AB46B521C37B750006B044 /* Build configuration list for PBXNativeTarget "WMZCodeUITests" */ = { 587 | isa = XCConfigurationList; 588 | buildConfigurations = ( 589 | 18AB46B621C37B750006B044 /* Debug */, 590 | 18AB46B721C37B750006B044 /* Release */, 591 | ); 592 | defaultConfigurationIsVisible = 0; 593 | defaultConfigurationName = Release; 594 | }; 595 | /* End XCConfigurationList section */ 596 | }; 597 | rootObject = 18AB467B21C37B6D0006B044 /* Project object */; 598 | } 599 | -------------------------------------------------------------------------------- /WMZCode.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /WMZCode.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /WMZCode.xcodeproj/project.xcworkspace/xcuserdata/wmz.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwmz/WMZCode/2e68b0cb7c449fa102b97e2d38251b19a45a9517/WMZCode.xcodeproj/project.xcworkspace/xcuserdata/wmz.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /WMZCode.xcodeproj/xcuserdata/apple.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /WMZCode.xcodeproj/xcuserdata/wmz.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | WMZCode.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /WMZCode/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // WMZCode 4 | // 5 | // Created by wmz on 2018/12/14. 6 | // Copyright © 2018年 wmz. 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 | -------------------------------------------------------------------------------- /WMZCode/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // WMZCode 4 | // 5 | // Created by wmz on 2018/12/14. 6 | // Copyright © 2018年 wmz. 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 | -------------------------------------------------------------------------------- /WMZCode/Assets.xcassets/A.imageset/A.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwmz/WMZCode/2e68b0cb7c449fa102b97e2d38251b19a45a9517/WMZCode/Assets.xcassets/A.imageset/A.png -------------------------------------------------------------------------------- /WMZCode/Assets.xcassets/A.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "A.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /WMZCode/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /WMZCode/Assets.xcassets/B.imageset/B.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwmz/WMZCode/2e68b0cb7c449fa102b97e2d38251b19a45a9517/WMZCode/Assets.xcassets/B.imageset/B.png -------------------------------------------------------------------------------- /WMZCode/Assets.xcassets/B.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "B.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /WMZCode/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /WMZCode/Assets.xcassets/SliderBtn.imageset/A60FD1B7CBF08631A978DC3E57B4F221.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwmz/WMZCode/2e68b0cb7c449fa102b97e2d38251b19a45a9517/WMZCode/Assets.xcassets/SliderBtn.imageset/A60FD1B7CBF08631A978DC3E57B4F221.png -------------------------------------------------------------------------------- /WMZCode/Assets.xcassets/SliderBtn.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "A60FD1B7CBF08631A978DC3E57B4F221.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /WMZCode/Assets.xcassets/refresh.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "refresh.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /WMZCode/Assets.xcassets/refresh.imageset/refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwmz/WMZCode/2e68b0cb7c449fa102b97e2d38251b19a45a9517/WMZCode/Assets.xcassets/refresh.imageset/refresh.png -------------------------------------------------------------------------------- /WMZCode/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 | -------------------------------------------------------------------------------- /WMZCode/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 | -------------------------------------------------------------------------------- /WMZCode/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.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 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /WMZCode/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // WMZCode 4 | // 5 | // Created by wmz on 2018/12/14. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /WMZCode/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // WMZCode 4 | // 5 | // Created by wmz on 2018/12/14. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "WMZCodeView.h" 11 | @interface ViewController () 12 | 13 | @property(nonatomic,strong)WMZCodeView *codeView; 14 | 15 | @end 16 | 17 | @implementation ViewController 18 | 19 | - (void)viewDidLoad { 20 | [super viewDidLoad]; 21 | // Do any additional setup after loading the view, typically from a nib. 22 | 23 | NSArray *arr = @[@"拼图验证",@"点击文本验证",@"九宫格验证",@"滑动验证"]; 24 | 25 | for (int i = 0; i 10 | 11 | /* 12 | * CodeType type 13 | */ 14 | typedef NS_ENUM(NSInteger, CodeType) { 15 | CodeTypeImage = 0, // DefaultImage 16 | CodeTypeLabel, // Label 17 | CodeTypeNineLabel, // NineLabel 18 | CodeTypeSlider // Slider 19 | }; 20 | 21 | 22 | typedef void (^callBack) (BOOL success); 23 | 24 | NS_ASSUME_NONNULL_BEGIN 25 | 26 | @interface WMZCodeView : UIView 27 | 28 | /* 29 | * 初始化 30 | */ 31 | + (instancetype)shareInstance; 32 | 33 | /* 34 | * 调用方法 35 | * 36 | * @param CodeType 类型 37 | * @param name 背景图 38 | * @param rect frame 39 | * @param block 回调 40 | * 41 | */ 42 | - (WMZCodeView*)addCodeViewWithType:(CodeType)type 43 | withImageName:(NSString*)name 44 | witgFrame:(CGRect)rect 45 | withBlock:(callBack)block; 46 | 47 | @end 48 | 49 | 50 | 51 | @interface WMZSlider : UISlider 52 | 53 | @property(nonatomic,strong)UILabel *label; 54 | 55 | @end 56 | 57 | 58 | typedef NS_ENUM(NSInteger,DWContentMode)//图片填充模式 59 | { 60 | DWContentModeScaleAspectFit,//适应模式 61 | DWContentModeScaleAspectFill,//填充模式 62 | DWContentModeScaleToFill//拉伸模式 63 | }; 64 | 65 | 66 | @interface UIImage (Expand) 67 | 68 | ///截取当前image对象rect区域内的图像 69 | -(UIImage *)dw_SubImageWithRect:(CGRect)rect; 70 | 71 | ///压缩图片至指定尺寸 72 | -(UIImage *)dw_RescaleImageToSize:(CGSize)size; 73 | 74 | ///按给定path剪裁图片 75 | /** 76 | path:路径,剪裁区域。 77 | mode:填充模式 78 | */ 79 | -(UIImage *)dw_ClipImageWithPath:(UIBezierPath *)path mode:(DWContentMode)mode; 80 | 81 | //裁剪图片 82 | - (UIImage*)imageScaleToSize:(CGSize)size; 83 | 84 | @end 85 | 86 | 87 | NS_ASSUME_NONNULL_END 88 | -------------------------------------------------------------------------------- /WMZCode/WMZCode/WMZCodeView.m: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | // 9 | // WMZCodeView.m 10 | // WMZCode 11 | // 12 | // Created by wmz on 2018/12/14. 13 | // Copyright © 2018年 wmz. All rights reserved. 14 | // 15 | 16 | 17 | //间距 18 | #define margin 10 19 | 20 | //滑块大小 21 | #define codeSize 50 22 | 23 | //贝塞尔曲线偏移 24 | #define offset 9 25 | 26 | //背景图片宽度 27 | #define imageHeight 200 28 | 29 | //滑块高度 30 | #define sliderHeight 40 31 | 32 | //默认需要点击文本的数量 33 | #define codeLabelCount 4 34 | 35 | //默认还需要添加的点击文本的数量 36 | #define codeAddLabelCount 3 37 | 38 | //字体 39 | #define WMZfont 24 40 | 41 | #import "WMZCodeView.h" 42 | @interface WMZCodeView() 43 | { 44 | dispatch_source_t timer; //定时器 45 | } 46 | @property(nonatomic,copy)NSString *name; //文本图片 默认图片“A” 47 | 48 | @property(nonatomic,copy)callBack block; //回调 49 | 50 | @property(nonatomic,assign)CodeType type; //类型 51 | 52 | @property(nonatomic,strong)UILabel *tipLabel; //提示文本 53 | 54 | @property(nonatomic,strong)UIImageView *mainImage; //背景图片 55 | 56 | @property(nonatomic,strong)UIImageView *moveImage; //可移动图片 57 | 58 | @property(nonatomic,strong)CAShapeLayer *maskLayer; //遮罩层layer 59 | 60 | @property(nonatomic,strong)UIView *maskView; //遮罩层 61 | 62 | @property(nonatomic,assign)CGPoint randomPoint; //随机位置 63 | 64 | @property(nonatomic,strong)WMZSlider *WMZSlider; //自定义滑动 65 | 66 | @property(nonatomic,strong)WMZSlider *slider; //滑动 67 | 68 | @property(nonatomic,strong)UIButton *refresh; //刷新按钮 69 | 70 | @property(nonatomic,assign)CGFloat width; //self的frame的width 71 | 72 | @property(nonatomic,assign)CGFloat height; //self的frame的height 73 | 74 | @property(nonatomic,copy)NSString *allChinese; //所显示的所有中文 75 | 76 | @property(nonatomic,copy)NSString *factChinese; //实际需要点击的中文 77 | 78 | @property(nonatomic,copy)NSString *selectChinese; //点击的中文 79 | 80 | @property(nonatomic,assign)int tapCount; //点击数量 81 | 82 | @property(nonatomic,strong)NSMutableArray *btnArr; //按钮数组 83 | 84 | @property(nonatomic,assign)CGFloat seconds; //秒数 85 | 86 | @property(nonatomic,strong)UIView *nineView; //九宫格view 87 | 88 | @end 89 | @implementation WMZCodeView 90 | /* 91 | * 初始化 92 | */ 93 | + (instancetype)shareInstance{ 94 | return [[self alloc]init]; 95 | } 96 | 97 | /* 98 | * 调用方法 99 | * 100 | * @param CodeType 类型 101 | * @param name 背景图 102 | * @param rect frame 103 | * @param block 回调 104 | * 105 | */ 106 | - (WMZCodeView*)addCodeViewWithType:(CodeType)type withImageName:(NSString*)name witgFrame:(CGRect)rect withBlock:(callBack)block{ 107 | self.frame = rect; 108 | self.name = [name copy]; 109 | self.type = type; 110 | self.block = block; 111 | [self addViewWithType:type]; 112 | return self; 113 | } 114 | 115 | //根据type不同进行布局 116 | - (void)addViewWithType:(CodeType)type{ 117 | switch (type) { 118 | case CodeTypeImage: 119 | { 120 | [self CodeTypeImageView]; 121 | } 122 | break; 123 | case CodeTypeLabel: 124 | { 125 | [self CodeTypeLabelView]; 126 | } 127 | break; 128 | case CodeTypeNineLabel: 129 | { 130 | [self CodeTypeLabelView]; 131 | } 132 | break; 133 | case CodeTypeSlider: 134 | { 135 | [self CodeTypeSliderView]; 136 | } 137 | break; 138 | } 139 | } 140 | 141 | //CodeTypeImage 142 | - (void)CodeTypeImageView{ 143 | [self addSubview:({ 144 | self.tipLabel.text = @"拖动下方滑块完成拼图"; 145 | self.tipLabel.frame = CGRectMake(margin, margin, self.width-margin*2, 30); 146 | self.tipLabel; 147 | })]; 148 | 149 | [self addSubview:({ 150 | self.mainImage.frame = CGRectMake(margin, CGRectGetMaxY(self.tipLabel.frame)+margin, self.width-margin*2, imageHeight); 151 | self.mainImage.contentMode = UIViewContentModeScaleAspectFill; 152 | self.mainImage.clipsToBounds = YES; 153 | self.mainImage; 154 | })]; 155 | 156 | [self addSubview:({ 157 | self.slider.frame = CGRectMake(margin, CGRectGetMaxY(self.mainImage.frame)+margin, self.width-margin*2, 30); 158 | [self.slider addTarget:self action:@selector(buttonAction:forEvent:) forControlEvents:UIControlEventAllTouchEvents]; 159 | self.slider.layer.masksToBounds = YES; 160 | self.slider.layer.cornerRadius = 15; 161 | self.slider; 162 | })]; 163 | 164 | [self addSubview:({ 165 | self.refresh.frame = CGRectMake(self.width-margin-50, CGRectGetMaxY(self.slider.frame)+margin, 40, 40); 166 | [self.refresh setImage:[UIImage imageNamed:@"refresh"] forState:UIControlStateNormal]; 167 | [self.refresh addTarget:self action:@selector(refreshAction) forControlEvents:UIControlEventTouchUpInside]; 168 | self.refresh; 169 | })]; 170 | 171 | CGRect rect = self.frame; 172 | rect.size.height = CGRectGetMaxY(self.refresh.frame)+margin; 173 | self.frame = rect; 174 | 175 | [self refreshAction]; 176 | 177 | } 178 | 179 | //CodeTypeLabel and CodeTypeNineLabel 180 | - (void)CodeTypeLabelView{ 181 | [self addSubview:({ 182 | [self setMyTipLabetText]; 183 | self.tipLabel.frame = CGRectMake(margin, margin, self.width-margin*2, 30); 184 | self.tipLabel; 185 | })]; 186 | 187 | [self addSubview:({ 188 | self.mainImage.frame = CGRectMake(margin, CGRectGetMaxY(self.tipLabel.frame)+margin, self.width-margin*2, imageHeight); 189 | self.mainImage.image = [UIImage imageNamed:self.name]; 190 | self.mainImage.contentMode = UIViewContentModeScaleAspectFill; 191 | self.mainImage.clipsToBounds = YES; 192 | self.mainImage.userInteractionEnabled = YES; 193 | self.mainImage; 194 | })]; 195 | 196 | [self addSubview:({ 197 | self.refresh.frame = CGRectMake(self.width-margin-50, CGRectGetMaxY(self.mainImage.frame)+margin, 40, 40); 198 | [self.refresh setImage:[UIImage imageNamed:@"refresh"] forState:UIControlStateNormal]; 199 | [self.refresh addTarget:self action:@selector(refreshAction) forControlEvents:UIControlEventTouchUpInside]; 200 | self.refresh; 201 | })]; 202 | 203 | CGRect rect = self.frame; 204 | rect.size.height = CGRectGetMaxY(self.refresh.frame)+margin; 205 | self.frame = rect; 206 | 207 | 208 | [self addLabelImage]; 209 | } 210 | 211 | //CodeTypeSlider 212 | - (void)CodeTypeSliderView{ 213 | 214 | if (self.height<40) { 215 | self.height = 40; 216 | } 217 | 218 | self.WMZSlider.frame = CGRectMake(margin-3, -3, self.width-2*margin+6,self.height+6); 219 | self.WMZSlider.minimumTrackTintColor = [UIColor clearColor]; 220 | self.WMZSlider.maximumTrackTintColor = [UIColor clearColor]; 221 | UIImage *tempImage = [UIImage imageNamed:@"SliderBtn"]; 222 | tempImage = [tempImage imageScaleToSize:CGSizeMake(self.height+6, self.height+6)]; 223 | [self.WMZSlider setThumbImage:tempImage forState:UIControlStateNormal]; 224 | [self.WMZSlider setThumbImage:tempImage forState:UIControlStateHighlighted]; 225 | 226 | 227 | [self.WMZSlider addTarget:self action:@selector(sliderValueChanged:) forControlEvents:UIControlEventValueChanged]; 228 | [self addSubview:self.WMZSlider]; 229 | 230 | self.WMZSlider.label.frame = CGRectMake(margin, 0, self.width-2*margin, self.height); 231 | [self addSubview:self.WMZSlider.label]; 232 | 233 | self.WMZSlider.label.layer.masksToBounds = YES; 234 | self.WMZSlider.label.layer.cornerRadius = (self.height)/2; 235 | 236 | self.WMZSlider.layer.masksToBounds = YES; 237 | self.WMZSlider.layer.cornerRadius = (self.height+6)/2; 238 | } 239 | 240 | //滑块滑动事件 241 | - (void)sliderValueChanged:(UISlider *)slider{ 242 | [self.WMZSlider setValue:slider.value animated:NO]; 243 | if (slider.value >0) { 244 | self.WMZSlider.minimumTrackTintColor = [UIColor redColor]; 245 | }else{ 246 | self.WMZSlider.minimumTrackTintColor = [UIColor clearColor]; 247 | } 248 | 249 | 250 | if (!slider.isTracking && slider.value != 1) { 251 | [self.WMZSlider setValue:0 animated:YES]; 252 | if (slider.value >0) { 253 | self.WMZSlider.minimumTrackTintColor = [UIColor redColor]; 254 | }else{ 255 | self.WMZSlider.minimumTrackTintColor = [UIColor clearColor]; 256 | } 257 | } 258 | if (!slider.isTracking&&slider.value==1) { 259 | [self.layer addAnimation:successAnimal() forKey:@"successAnimal"]; 260 | [self successShow]; 261 | } 262 | } 263 | 264 | //添加可移动的图片 265 | - (void)addMoveImage{ 266 | UIImage *normalImage = [UIImage imageNamed:self.name]; 267 | normalImage = [normalImage dw_RescaleImageToSize:CGSizeMake(self.width-margin*2, imageHeight)]; 268 | self.mainImage.image = normalImage; 269 | 270 | [self.mainImage addSubview:({ 271 | self.maskView.frame = CGRectMake(self.randomPoint.x, self.randomPoint.y, codeSize, codeSize); 272 | self.maskView; 273 | })]; 274 | 275 | UIBezierPath *path = getCodePath(); 276 | 277 | UIImage * thumbImage = [self.mainImage.image dw_SubImageWithRect:self.maskView.frame]; 278 | thumbImage = [thumbImage dw_ClipImageWithPath:path mode:(DWContentModeScaleToFill)]; 279 | [self.mainImage addSubview:({ 280 | self.moveImage.frame = CGRectMake(0, self.randomPoint.y-offset, codeSize+offset, codeSize+offset); 281 | self.moveImage.image = thumbImage; 282 | self.moveImage; 283 | })]; 284 | 285 | 286 | [self.maskView.layer addSublayer:({ 287 | self.maskLayer.frame = CGRectMake(0, 0, codeSize, codeSize); 288 | self.maskLayer.path = path.CGPath; 289 | self.maskLayer.strokeColor = [UIColor whiteColor].CGColor; 290 | self.maskLayer; 291 | })]; 292 | 293 | } 294 | 295 | //添加随机位置的文本 296 | - (void)addLabelImage{ 297 | NSMutableArray *tempArr = [NSMutableArray new]; 298 | for (int i = 0; i< self.allChinese.length; i++) { 299 | [tempArr addObject:[self.allChinese substringWithRange:NSMakeRange(i, 1)]]; 300 | } 301 | NSArray* arr = [NSArray arrayWithArray:tempArr]; 302 | arr = [arr sortedArrayUsingComparator:^NSComparisonResult(NSString *str1, NSString *str2) { 303 | int seed = arc4random_uniform(2); 304 | if (seed) { 305 | return [str1 compare:str2]; 306 | } else { 307 | return [str2 compare:str1]; 308 | } 309 | }]; 310 | 311 | NSMutableString *string = [[NSMutableString alloc]initWithString:@""]; 312 | for (int i = 0; iself.width-margin*2-codeSize) { 441 | slider.value = self.width-margin*2-codeSize; 442 | return; 443 | } 444 | [self changeSliderWithVlue:slider.value]; 445 | 446 | } 447 | } 448 | 449 | //设置默认的滑动 450 | - (void)defaultSlider{ 451 | self.slider.value = 0.05; 452 | [self changeSliderWithVlue:self.slider.value]; 453 | } 454 | 455 | //图片位置随着Slider滑动改变frame 456 | - (void)changeSliderWithVlue:(CGFloat)value{ 457 | CGRect rect = self.moveImage.frame; 458 | CGFloat x = value * (self.mainImage.frame.size.width)-(value*codeSize); 459 | rect.origin.x = x; 460 | self.moveImage.frame = rect; 461 | } 462 | 463 | //恢复默认数据(CodeTypeLabel,CodeTypeNineLabel ) 464 | - (void)defaultBtnAndData{ 465 | self.selectChinese = @""; 466 | self.tapCount = 0; 467 | for (int i = 0; i0) { 542 | tip = [NSString stringWithFormat:@"耗时%.1fs",self.seconds]; 543 | } 544 | UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"验证成功" message:tip preferredStyle:UIAlertControllerStyleAlert]; 545 | UIAlertAction *action = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { 546 | if (codeView.block) { 547 | codeView.block(YES); 548 | } 549 | [codeView refreshAction]; 550 | }]; 551 | [alert addAction:action]; 552 | [[self getCurrentVC] presentViewController:alert animated:YES completion:nil]; 553 | }); 554 | 555 | } 556 | 557 | //获取当前VC 558 | - (UIViewController *)getCurrentVC 559 | { 560 | UIViewController *rootViewController = [UIApplication sharedApplication].keyWindow.rootViewController; 561 | 562 | UIViewController *currentVC = [self getCurrentVCFrom:rootViewController]; 563 | 564 | return currentVC; 565 | } 566 | 567 | - (UIViewController *)getCurrentVCFrom:(UIViewController *)rootVC 568 | { 569 | UIViewController *currentVC; 570 | 571 | if ([rootVC presentedViewController]) { 572 | // 视图是被presented出来的 573 | rootVC = [rootVC presentedViewController]; 574 | } 575 | 576 | if ([rootVC isKindOfClass:[UITabBarController class]]) { 577 | // 根视图为UITabBarController 578 | currentVC = [self getCurrentVCFrom:[(UITabBarController *)rootVC selectedViewController]]; 579 | 580 | } else if ([rootVC isKindOfClass:[UINavigationController class]]){ 581 | // 根视图为UINavigationController 582 | currentVC = [self getCurrentVCFrom:[(UINavigationController *)rootVC visibleViewController]]; 583 | 584 | } else { 585 | // 根视图为非导航类 586 | currentVC = rootVC; 587 | } 588 | return currentVC; 589 | } 590 | 591 | /** 592 | 配置滑块贝塞尔曲线 593 | */ 594 | static inline UIBezierPath* getCodePath(){ 595 | UIBezierPath *path = [UIBezierPath bezierPath]; 596 | [path moveToPoint:CGPointMake(0, 0)]; 597 | [path addLineToPoint:CGPointMake(codeSize*0.5-offset,0)]; 598 | [path addQuadCurveToPoint:CGPointMake(codeSize*0.5+offset, 0) controlPoint:CGPointMake(codeSize*0.5, -offset*2)]; 599 | [path addLineToPoint:CGPointMake(codeSize, 0)]; 600 | 601 | 602 | [path addLineToPoint:CGPointMake(codeSize,codeSize*0.5-offset)]; 603 | [path addQuadCurveToPoint:CGPointMake(codeSize, codeSize*0.5+offset) controlPoint:CGPointMake(codeSize+offset*2, codeSize*0.5)]; 604 | [path addLineToPoint:CGPointMake(codeSize, codeSize)]; 605 | 606 | [path addLineToPoint:CGPointMake(codeSize*0.5+offset,codeSize)]; 607 | [path addQuadCurveToPoint:CGPointMake(codeSize*0.5-offset, codeSize) controlPoint:CGPointMake(codeSize*0.5, codeSize-offset*2)]; 608 | [path addLineToPoint:CGPointMake(0, codeSize)]; 609 | 610 | [path addLineToPoint:CGPointMake(0,codeSize*0.5+offset)]; 611 | [path addQuadCurveToPoint:CGPointMake(0, codeSize*0.5-offset) controlPoint:CGPointMake(0+offset*2, codeSize*0.5)]; 612 | [path addLineToPoint:CGPointMake(0, 0)]; 613 | 614 | [path stroke]; 615 | return path; 616 | } 617 | 618 | //获取随机位置 619 | - (void)getRandomPoint{ 620 | CGFloat widthMax = self.mainImage.frame.size.width-margin-codeSize; 621 | CGFloat heightMax = self.mainImage.frame.size.height-codeSize*2; 622 | 623 | self.randomPoint = CGPointMake([self getRandomNumber:margin+codeSize*2 to:widthMax], [self getRandomNumber:offset*2 to:heightMax]); 624 | NSLog(@"%f %f",self.randomPoint.x,self.randomPoint.y); 625 | } 626 | 627 | //获取一个随机整数,范围在[from, to],包括from,包括to 628 | - (int)getRandomNumber:(int)from to:(int)to { 629 | return (int)(from + (arc4random() % (to - from + 1))); 630 | } 631 | 632 | 633 | //获取随机数量中文 634 | - (NSString*)getRandomChineseWithCount:(NSInteger)count{ 635 | 636 | NSMutableString *mString = [[NSMutableString alloc]initWithString:@""]; 637 | NSStringEncoding gbkEncoding = CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000); 638 | for (int i = 0; i boxBounds.size.height) { 827 | height = boxBounds.size.height; 828 | width = height * originScale; 829 | } 830 | } 831 | break; 832 | case DWContentModeScaleAspectFill: 833 | { 834 | if (height < boxBounds.size.height) { 835 | height = boxBounds.size.height; 836 | width = height * originScale; 837 | } 838 | } 839 | break; 840 | default: 841 | if (height != boxBounds.size.height) { 842 | height = boxBounds.size.height; 843 | } 844 | break; 845 | } 846 | 847 | ///开启上下文 848 | UIGraphicsBeginImageContextWithOptions(boxBounds.size, NO, [UIScreen mainScreen].scale); 849 | CGContextRef bitmap = UIGraphicsGetCurrentContext(); 850 | 851 | ///归零path 852 | UIBezierPath * newPath = [path copy]; 853 | [newPath applyTransform:CGAffineTransformMakeTranslation(-path.bounds.origin.x, -path.bounds.origin.y)]; 854 | [newPath addClip]; 855 | 856 | ///移动原点至图片中心 857 | CGContextTranslateCTM(bitmap, boxBounds.size.width / 2.0, boxBounds.size.height / 2.0); 858 | CGContextScaleCTM(bitmap, 1.0, -1.0); 859 | CGContextDrawImage(bitmap, CGRectMake(-width / 2, -height / 2, width, height), self.CGImage); 860 | 861 | ///生成图片 862 | UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); 863 | UIGraphicsEndImageContext(); 864 | 865 | return newImage; 866 | } 867 | 868 | //裁剪图片 869 | - (UIImage*)imageScaleToSize:(CGSize)size{ 870 | UIGraphicsBeginImageContext(size);//size为CGSize类型,即你所需要的图片尺寸 871 | [self drawInRect:CGRectMake(0,0, size.width, size.height)]; 872 | UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext(); 873 | UIGraphicsEndImageContext(); 874 | 875 | return scaledImage; 876 | } 877 | 878 | @end 879 | -------------------------------------------------------------------------------- /WMZCode/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // WMZCode 4 | // 5 | // Created by wmz on 2018/12/14. 6 | // Copyright © 2018年 wmz. 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 | -------------------------------------------------------------------------------- /WMZCodeTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /WMZCodeTests/WMZCodeTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // WMZCodeTests.m 3 | // WMZCodeTests 4 | // 5 | // Created by wmz on 2018/12/14. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface WMZCodeTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation WMZCodeTests 16 | 17 | - (void)setUp { 18 | // Put setup code here. This method is called before the invocation of each test method in the class. 19 | } 20 | 21 | - (void)tearDown { 22 | // Put teardown code here. This method is called after the invocation of each test method in the class. 23 | } 24 | 25 | - (void)testExample { 26 | // This is an example of a functional test case. 27 | // Use XCTAssert and related functions to verify your tests produce the correct results. 28 | } 29 | 30 | - (void)testPerformanceExample { 31 | // This is an example of a performance test case. 32 | [self measureBlock:^{ 33 | // Put the code you want to measure the time of here. 34 | }]; 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /WMZCodeUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /WMZCodeUITests/WMZCodeUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // WMZCodeUITests.m 3 | // WMZCodeUITests 4 | // 5 | // Created by wmz on 2018/12/14. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface WMZCodeUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation WMZCodeUITests 16 | 17 | - (void)setUp { 18 | // Put setup code here. This method is called before the invocation of each test method in the class. 19 | 20 | // In UI tests it is usually best to stop immediately when a failure occurs. 21 | self.continueAfterFailure = NO; 22 | 23 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 24 | [[[XCUIApplication alloc] init] launch]; 25 | 26 | // 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. 27 | } 28 | 29 | - (void)tearDown { 30 | // Put teardown code here. This method is called after the invocation of each test method in the class. 31 | } 32 | 33 | - (void)testExample { 34 | // Use recording to get started writing UI tests. 35 | // Use XCTAssert and related functions to verify your tests produce the correct results. 36 | } 37 | 38 | @end 39 | --------------------------------------------------------------------------------