├── LICENSE ├── README.md ├── UIBezierPath_And_CAShapeLayer.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── huangyibiao.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── huangyibiao.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── UIBezierPath_And_CAShapeLayer.xcscheme │ └── xcschememanagement.plist ├── UIBezierPath_And_CAShapeLayer ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── BezierPathView.h ├── BezierPathView.m ├── Info.plist ├── ViewController.h ├── ViewController.m └── main.m ├── UIBezierPath_And_CAShapeLayerTests ├── Info.plist └── UIBezierPath_And_CAShapeLayerTests.m └── UIBezierPath_And_CAShapeLayerUITests ├── Info.plist └── UIBezierPath_And_CAShapeLayerUITests.m /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 JackyHuang 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # UIBezierPathLayerDemos 2 | 学习贝塞尔曲线及层动画相关 3 | 4 | #本Demo源代码讲解 5 | 6 | [iOS UIBezierPath精讲](http://www.henishuo.com/uibezierpath-draw/) 7 | 8 | [iOS CAShapeLayer精讲](http://www.henishuo.com/ios-cashapelayer-learning/) 9 | 10 | #关注我 11 | 12 | **微信公众号:[iOSDevShares](http://www.henishuo.com/)**
13 | **有问必答QQ群:[324400294](http://www.henishuo.com/)** 14 | 15 | 16 | -------------------------------------------------------------------------------- /UIBezierPath_And_CAShapeLayer.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 69773C561C0D733E0004E2F6 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 69773C551C0D733E0004E2F6 /* main.m */; }; 11 | 69773C591C0D733E0004E2F6 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 69773C581C0D733E0004E2F6 /* AppDelegate.m */; }; 12 | 69773C5C1C0D733E0004E2F6 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 69773C5B1C0D733E0004E2F6 /* ViewController.m */; }; 13 | 69773C5F1C0D733E0004E2F6 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 69773C5D1C0D733E0004E2F6 /* Main.storyboard */; }; 14 | 69773C611C0D733E0004E2F6 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 69773C601C0D733E0004E2F6 /* Assets.xcassets */; }; 15 | 69773C641C0D733E0004E2F6 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 69773C621C0D733E0004E2F6 /* LaunchScreen.storyboard */; }; 16 | 69773C6F1C0D733E0004E2F6 /* UIBezierPath_And_CAShapeLayerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 69773C6E1C0D733E0004E2F6 /* UIBezierPath_And_CAShapeLayerTests.m */; }; 17 | 69773C7A1C0D733E0004E2F6 /* UIBezierPath_And_CAShapeLayerUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 69773C791C0D733E0004E2F6 /* UIBezierPath_And_CAShapeLayerUITests.m */; }; 18 | 69773C891C0E8A6E0004E2F6 /* BezierPathView.m in Sources */ = {isa = PBXBuildFile; fileRef = 69773C881C0E8A6E0004E2F6 /* BezierPathView.m */; }; 19 | 69773C8A1C0E8A6E0004E2F6 /* BezierPathView.m in Sources */ = {isa = PBXBuildFile; fileRef = 69773C881C0E8A6E0004E2F6 /* BezierPathView.m */; }; 20 | 69773C8B1C0E8A6E0004E2F6 /* BezierPathView.m in Sources */ = {isa = PBXBuildFile; fileRef = 69773C881C0E8A6E0004E2F6 /* BezierPathView.m */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXContainerItemProxy section */ 24 | 69773C6B1C0D733E0004E2F6 /* PBXContainerItemProxy */ = { 25 | isa = PBXContainerItemProxy; 26 | containerPortal = 69773C491C0D733E0004E2F6 /* Project object */; 27 | proxyType = 1; 28 | remoteGlobalIDString = 69773C501C0D733E0004E2F6; 29 | remoteInfo = UIBezierPath_And_CAShapeLayer; 30 | }; 31 | 69773C761C0D733E0004E2F6 /* PBXContainerItemProxy */ = { 32 | isa = PBXContainerItemProxy; 33 | containerPortal = 69773C491C0D733E0004E2F6 /* Project object */; 34 | proxyType = 1; 35 | remoteGlobalIDString = 69773C501C0D733E0004E2F6; 36 | remoteInfo = UIBezierPath_And_CAShapeLayer; 37 | }; 38 | /* End PBXContainerItemProxy section */ 39 | 40 | /* Begin PBXFileReference section */ 41 | 69773C511C0D733E0004E2F6 /* UIBezierPath_And_CAShapeLayer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = UIBezierPath_And_CAShapeLayer.app; sourceTree = BUILT_PRODUCTS_DIR; }; 42 | 69773C551C0D733E0004E2F6 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 43 | 69773C571C0D733E0004E2F6 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 44 | 69773C581C0D733E0004E2F6 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 45 | 69773C5A1C0D733E0004E2F6 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 46 | 69773C5B1C0D733E0004E2F6 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 47 | 69773C5E1C0D733E0004E2F6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 48 | 69773C601C0D733E0004E2F6 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 49 | 69773C631C0D733E0004E2F6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 50 | 69773C651C0D733E0004E2F6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 51 | 69773C6A1C0D733E0004E2F6 /* UIBezierPath_And_CAShapeLayerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UIBezierPath_And_CAShapeLayerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 52 | 69773C6E1C0D733E0004E2F6 /* UIBezierPath_And_CAShapeLayerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = UIBezierPath_And_CAShapeLayerTests.m; sourceTree = ""; }; 53 | 69773C701C0D733E0004E2F6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 54 | 69773C751C0D733E0004E2F6 /* UIBezierPath_And_CAShapeLayerUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UIBezierPath_And_CAShapeLayerUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 55 | 69773C791C0D733E0004E2F6 /* UIBezierPath_And_CAShapeLayerUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = UIBezierPath_And_CAShapeLayerUITests.m; sourceTree = ""; }; 56 | 69773C7B1C0D733E0004E2F6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 57 | 69773C871C0E8A6E0004E2F6 /* BezierPathView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BezierPathView.h; sourceTree = ""; }; 58 | 69773C881C0E8A6E0004E2F6 /* BezierPathView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BezierPathView.m; sourceTree = ""; }; 59 | /* End PBXFileReference section */ 60 | 61 | /* Begin PBXFrameworksBuildPhase section */ 62 | 69773C4E1C0D733E0004E2F6 /* Frameworks */ = { 63 | isa = PBXFrameworksBuildPhase; 64 | buildActionMask = 2147483647; 65 | files = ( 66 | ); 67 | runOnlyForDeploymentPostprocessing = 0; 68 | }; 69 | 69773C671C0D733E0004E2F6 /* Frameworks */ = { 70 | isa = PBXFrameworksBuildPhase; 71 | buildActionMask = 2147483647; 72 | files = ( 73 | ); 74 | runOnlyForDeploymentPostprocessing = 0; 75 | }; 76 | 69773C721C0D733E0004E2F6 /* Frameworks */ = { 77 | isa = PBXFrameworksBuildPhase; 78 | buildActionMask = 2147483647; 79 | files = ( 80 | ); 81 | runOnlyForDeploymentPostprocessing = 0; 82 | }; 83 | /* End PBXFrameworksBuildPhase section */ 84 | 85 | /* Begin PBXGroup section */ 86 | 69773C481C0D733E0004E2F6 = { 87 | isa = PBXGroup; 88 | children = ( 89 | 69773C531C0D733E0004E2F6 /* UIBezierPath_And_CAShapeLayer */, 90 | 69773C6D1C0D733E0004E2F6 /* UIBezierPath_And_CAShapeLayerTests */, 91 | 69773C781C0D733E0004E2F6 /* UIBezierPath_And_CAShapeLayerUITests */, 92 | 69773C521C0D733E0004E2F6 /* Products */, 93 | ); 94 | sourceTree = ""; 95 | }; 96 | 69773C521C0D733E0004E2F6 /* Products */ = { 97 | isa = PBXGroup; 98 | children = ( 99 | 69773C511C0D733E0004E2F6 /* UIBezierPath_And_CAShapeLayer.app */, 100 | 69773C6A1C0D733E0004E2F6 /* UIBezierPath_And_CAShapeLayerTests.xctest */, 101 | 69773C751C0D733E0004E2F6 /* UIBezierPath_And_CAShapeLayerUITests.xctest */, 102 | ); 103 | name = Products; 104 | sourceTree = ""; 105 | }; 106 | 69773C531C0D733E0004E2F6 /* UIBezierPath_And_CAShapeLayer */ = { 107 | isa = PBXGroup; 108 | children = ( 109 | 69773C571C0D733E0004E2F6 /* AppDelegate.h */, 110 | 69773C581C0D733E0004E2F6 /* AppDelegate.m */, 111 | 69773C5A1C0D733E0004E2F6 /* ViewController.h */, 112 | 69773C5B1C0D733E0004E2F6 /* ViewController.m */, 113 | 69773C5D1C0D733E0004E2F6 /* Main.storyboard */, 114 | 69773C601C0D733E0004E2F6 /* Assets.xcassets */, 115 | 69773C621C0D733E0004E2F6 /* LaunchScreen.storyboard */, 116 | 69773C651C0D733E0004E2F6 /* Info.plist */, 117 | 69773C541C0D733E0004E2F6 /* Supporting Files */, 118 | 69773C871C0E8A6E0004E2F6 /* BezierPathView.h */, 119 | 69773C881C0E8A6E0004E2F6 /* BezierPathView.m */, 120 | ); 121 | path = UIBezierPath_And_CAShapeLayer; 122 | sourceTree = ""; 123 | }; 124 | 69773C541C0D733E0004E2F6 /* Supporting Files */ = { 125 | isa = PBXGroup; 126 | children = ( 127 | 69773C551C0D733E0004E2F6 /* main.m */, 128 | ); 129 | name = "Supporting Files"; 130 | sourceTree = ""; 131 | }; 132 | 69773C6D1C0D733E0004E2F6 /* UIBezierPath_And_CAShapeLayerTests */ = { 133 | isa = PBXGroup; 134 | children = ( 135 | 69773C6E1C0D733E0004E2F6 /* UIBezierPath_And_CAShapeLayerTests.m */, 136 | 69773C701C0D733E0004E2F6 /* Info.plist */, 137 | ); 138 | path = UIBezierPath_And_CAShapeLayerTests; 139 | sourceTree = ""; 140 | }; 141 | 69773C781C0D733E0004E2F6 /* UIBezierPath_And_CAShapeLayerUITests */ = { 142 | isa = PBXGroup; 143 | children = ( 144 | 69773C791C0D733E0004E2F6 /* UIBezierPath_And_CAShapeLayerUITests.m */, 145 | 69773C7B1C0D733E0004E2F6 /* Info.plist */, 146 | ); 147 | path = UIBezierPath_And_CAShapeLayerUITests; 148 | sourceTree = ""; 149 | }; 150 | /* End PBXGroup section */ 151 | 152 | /* Begin PBXNativeTarget section */ 153 | 69773C501C0D733E0004E2F6 /* UIBezierPath_And_CAShapeLayer */ = { 154 | isa = PBXNativeTarget; 155 | buildConfigurationList = 69773C7E1C0D733E0004E2F6 /* Build configuration list for PBXNativeTarget "UIBezierPath_And_CAShapeLayer" */; 156 | buildPhases = ( 157 | 69773C4D1C0D733E0004E2F6 /* Sources */, 158 | 69773C4E1C0D733E0004E2F6 /* Frameworks */, 159 | 69773C4F1C0D733E0004E2F6 /* Resources */, 160 | ); 161 | buildRules = ( 162 | ); 163 | dependencies = ( 164 | ); 165 | name = UIBezierPath_And_CAShapeLayer; 166 | productName = UIBezierPath_And_CAShapeLayer; 167 | productReference = 69773C511C0D733E0004E2F6 /* UIBezierPath_And_CAShapeLayer.app */; 168 | productType = "com.apple.product-type.application"; 169 | }; 170 | 69773C691C0D733E0004E2F6 /* UIBezierPath_And_CAShapeLayerTests */ = { 171 | isa = PBXNativeTarget; 172 | buildConfigurationList = 69773C811C0D733E0004E2F6 /* Build configuration list for PBXNativeTarget "UIBezierPath_And_CAShapeLayerTests" */; 173 | buildPhases = ( 174 | 69773C661C0D733E0004E2F6 /* Sources */, 175 | 69773C671C0D733E0004E2F6 /* Frameworks */, 176 | 69773C681C0D733E0004E2F6 /* Resources */, 177 | ); 178 | buildRules = ( 179 | ); 180 | dependencies = ( 181 | 69773C6C1C0D733E0004E2F6 /* PBXTargetDependency */, 182 | ); 183 | name = UIBezierPath_And_CAShapeLayerTests; 184 | productName = UIBezierPath_And_CAShapeLayerTests; 185 | productReference = 69773C6A1C0D733E0004E2F6 /* UIBezierPath_And_CAShapeLayerTests.xctest */; 186 | productType = "com.apple.product-type.bundle.unit-test"; 187 | }; 188 | 69773C741C0D733E0004E2F6 /* UIBezierPath_And_CAShapeLayerUITests */ = { 189 | isa = PBXNativeTarget; 190 | buildConfigurationList = 69773C841C0D733E0004E2F6 /* Build configuration list for PBXNativeTarget "UIBezierPath_And_CAShapeLayerUITests" */; 191 | buildPhases = ( 192 | 69773C711C0D733E0004E2F6 /* Sources */, 193 | 69773C721C0D733E0004E2F6 /* Frameworks */, 194 | 69773C731C0D733E0004E2F6 /* Resources */, 195 | ); 196 | buildRules = ( 197 | ); 198 | dependencies = ( 199 | 69773C771C0D733E0004E2F6 /* PBXTargetDependency */, 200 | ); 201 | name = UIBezierPath_And_CAShapeLayerUITests; 202 | productName = UIBezierPath_And_CAShapeLayerUITests; 203 | productReference = 69773C751C0D733E0004E2F6 /* UIBezierPath_And_CAShapeLayerUITests.xctest */; 204 | productType = "com.apple.product-type.bundle.ui-testing"; 205 | }; 206 | /* End PBXNativeTarget section */ 207 | 208 | /* Begin PBXProject section */ 209 | 69773C491C0D733E0004E2F6 /* Project object */ = { 210 | isa = PBXProject; 211 | attributes = { 212 | LastUpgradeCheck = 0710; 213 | ORGANIZATIONNAME = huangyibiao; 214 | TargetAttributes = { 215 | 69773C501C0D733E0004E2F6 = { 216 | CreatedOnToolsVersion = 7.1; 217 | }; 218 | 69773C691C0D733E0004E2F6 = { 219 | CreatedOnToolsVersion = 7.1; 220 | TestTargetID = 69773C501C0D733E0004E2F6; 221 | }; 222 | 69773C741C0D733E0004E2F6 = { 223 | CreatedOnToolsVersion = 7.1; 224 | TestTargetID = 69773C501C0D733E0004E2F6; 225 | }; 226 | }; 227 | }; 228 | buildConfigurationList = 69773C4C1C0D733E0004E2F6 /* Build configuration list for PBXProject "UIBezierPath_And_CAShapeLayer" */; 229 | compatibilityVersion = "Xcode 3.2"; 230 | developmentRegion = English; 231 | hasScannedForEncodings = 0; 232 | knownRegions = ( 233 | en, 234 | Base, 235 | ); 236 | mainGroup = 69773C481C0D733E0004E2F6; 237 | productRefGroup = 69773C521C0D733E0004E2F6 /* Products */; 238 | projectDirPath = ""; 239 | projectRoot = ""; 240 | targets = ( 241 | 69773C501C0D733E0004E2F6 /* UIBezierPath_And_CAShapeLayer */, 242 | 69773C691C0D733E0004E2F6 /* UIBezierPath_And_CAShapeLayerTests */, 243 | 69773C741C0D733E0004E2F6 /* UIBezierPath_And_CAShapeLayerUITests */, 244 | ); 245 | }; 246 | /* End PBXProject section */ 247 | 248 | /* Begin PBXResourcesBuildPhase section */ 249 | 69773C4F1C0D733E0004E2F6 /* Resources */ = { 250 | isa = PBXResourcesBuildPhase; 251 | buildActionMask = 2147483647; 252 | files = ( 253 | 69773C641C0D733E0004E2F6 /* LaunchScreen.storyboard in Resources */, 254 | 69773C611C0D733E0004E2F6 /* Assets.xcassets in Resources */, 255 | 69773C5F1C0D733E0004E2F6 /* Main.storyboard in Resources */, 256 | ); 257 | runOnlyForDeploymentPostprocessing = 0; 258 | }; 259 | 69773C681C0D733E0004E2F6 /* Resources */ = { 260 | isa = PBXResourcesBuildPhase; 261 | buildActionMask = 2147483647; 262 | files = ( 263 | ); 264 | runOnlyForDeploymentPostprocessing = 0; 265 | }; 266 | 69773C731C0D733E0004E2F6 /* Resources */ = { 267 | isa = PBXResourcesBuildPhase; 268 | buildActionMask = 2147483647; 269 | files = ( 270 | ); 271 | runOnlyForDeploymentPostprocessing = 0; 272 | }; 273 | /* End PBXResourcesBuildPhase section */ 274 | 275 | /* Begin PBXSourcesBuildPhase section */ 276 | 69773C4D1C0D733E0004E2F6 /* Sources */ = { 277 | isa = PBXSourcesBuildPhase; 278 | buildActionMask = 2147483647; 279 | files = ( 280 | 69773C891C0E8A6E0004E2F6 /* BezierPathView.m in Sources */, 281 | 69773C5C1C0D733E0004E2F6 /* ViewController.m in Sources */, 282 | 69773C591C0D733E0004E2F6 /* AppDelegate.m in Sources */, 283 | 69773C561C0D733E0004E2F6 /* main.m in Sources */, 284 | ); 285 | runOnlyForDeploymentPostprocessing = 0; 286 | }; 287 | 69773C661C0D733E0004E2F6 /* Sources */ = { 288 | isa = PBXSourcesBuildPhase; 289 | buildActionMask = 2147483647; 290 | files = ( 291 | 69773C8A1C0E8A6E0004E2F6 /* BezierPathView.m in Sources */, 292 | 69773C6F1C0D733E0004E2F6 /* UIBezierPath_And_CAShapeLayerTests.m in Sources */, 293 | ); 294 | runOnlyForDeploymentPostprocessing = 0; 295 | }; 296 | 69773C711C0D733E0004E2F6 /* Sources */ = { 297 | isa = PBXSourcesBuildPhase; 298 | buildActionMask = 2147483647; 299 | files = ( 300 | 69773C8B1C0E8A6E0004E2F6 /* BezierPathView.m in Sources */, 301 | 69773C7A1C0D733E0004E2F6 /* UIBezierPath_And_CAShapeLayerUITests.m in Sources */, 302 | ); 303 | runOnlyForDeploymentPostprocessing = 0; 304 | }; 305 | /* End PBXSourcesBuildPhase section */ 306 | 307 | /* Begin PBXTargetDependency section */ 308 | 69773C6C1C0D733E0004E2F6 /* PBXTargetDependency */ = { 309 | isa = PBXTargetDependency; 310 | target = 69773C501C0D733E0004E2F6 /* UIBezierPath_And_CAShapeLayer */; 311 | targetProxy = 69773C6B1C0D733E0004E2F6 /* PBXContainerItemProxy */; 312 | }; 313 | 69773C771C0D733E0004E2F6 /* PBXTargetDependency */ = { 314 | isa = PBXTargetDependency; 315 | target = 69773C501C0D733E0004E2F6 /* UIBezierPath_And_CAShapeLayer */; 316 | targetProxy = 69773C761C0D733E0004E2F6 /* PBXContainerItemProxy */; 317 | }; 318 | /* End PBXTargetDependency section */ 319 | 320 | /* Begin PBXVariantGroup section */ 321 | 69773C5D1C0D733E0004E2F6 /* Main.storyboard */ = { 322 | isa = PBXVariantGroup; 323 | children = ( 324 | 69773C5E1C0D733E0004E2F6 /* Base */, 325 | ); 326 | name = Main.storyboard; 327 | sourceTree = ""; 328 | }; 329 | 69773C621C0D733E0004E2F6 /* LaunchScreen.storyboard */ = { 330 | isa = PBXVariantGroup; 331 | children = ( 332 | 69773C631C0D733E0004E2F6 /* Base */, 333 | ); 334 | name = LaunchScreen.storyboard; 335 | sourceTree = ""; 336 | }; 337 | /* End PBXVariantGroup section */ 338 | 339 | /* Begin XCBuildConfiguration section */ 340 | 69773C7C1C0D733E0004E2F6 /* Debug */ = { 341 | isa = XCBuildConfiguration; 342 | buildSettings = { 343 | ALWAYS_SEARCH_USER_PATHS = NO; 344 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 345 | CLANG_CXX_LIBRARY = "libc++"; 346 | CLANG_ENABLE_MODULES = YES; 347 | CLANG_ENABLE_OBJC_ARC = YES; 348 | CLANG_WARN_BOOL_CONVERSION = YES; 349 | CLANG_WARN_CONSTANT_CONVERSION = YES; 350 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 351 | CLANG_WARN_EMPTY_BODY = YES; 352 | CLANG_WARN_ENUM_CONVERSION = YES; 353 | CLANG_WARN_INT_CONVERSION = YES; 354 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 355 | CLANG_WARN_UNREACHABLE_CODE = YES; 356 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 357 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 358 | COPY_PHASE_STRIP = NO; 359 | DEBUG_INFORMATION_FORMAT = dwarf; 360 | ENABLE_STRICT_OBJC_MSGSEND = YES; 361 | ENABLE_TESTABILITY = YES; 362 | GCC_C_LANGUAGE_STANDARD = gnu99; 363 | GCC_DYNAMIC_NO_PIC = NO; 364 | GCC_NO_COMMON_BLOCKS = YES; 365 | GCC_OPTIMIZATION_LEVEL = 0; 366 | GCC_PREPROCESSOR_DEFINITIONS = ( 367 | "DEBUG=1", 368 | "$(inherited)", 369 | ); 370 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 371 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 372 | GCC_WARN_UNDECLARED_SELECTOR = YES; 373 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 374 | GCC_WARN_UNUSED_FUNCTION = YES; 375 | GCC_WARN_UNUSED_VARIABLE = YES; 376 | IPHONEOS_DEPLOYMENT_TARGET = 9.1; 377 | MTL_ENABLE_DEBUG_INFO = YES; 378 | ONLY_ACTIVE_ARCH = YES; 379 | SDKROOT = iphoneos; 380 | }; 381 | name = Debug; 382 | }; 383 | 69773C7D1C0D733E0004E2F6 /* Release */ = { 384 | isa = XCBuildConfiguration; 385 | buildSettings = { 386 | ALWAYS_SEARCH_USER_PATHS = NO; 387 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 388 | CLANG_CXX_LIBRARY = "libc++"; 389 | CLANG_ENABLE_MODULES = YES; 390 | CLANG_ENABLE_OBJC_ARC = YES; 391 | CLANG_WARN_BOOL_CONVERSION = YES; 392 | CLANG_WARN_CONSTANT_CONVERSION = YES; 393 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 394 | CLANG_WARN_EMPTY_BODY = YES; 395 | CLANG_WARN_ENUM_CONVERSION = YES; 396 | CLANG_WARN_INT_CONVERSION = YES; 397 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 398 | CLANG_WARN_UNREACHABLE_CODE = YES; 399 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 400 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 401 | COPY_PHASE_STRIP = NO; 402 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 403 | ENABLE_NS_ASSERTIONS = NO; 404 | ENABLE_STRICT_OBJC_MSGSEND = YES; 405 | GCC_C_LANGUAGE_STANDARD = gnu99; 406 | GCC_NO_COMMON_BLOCKS = YES; 407 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 408 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 409 | GCC_WARN_UNDECLARED_SELECTOR = YES; 410 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 411 | GCC_WARN_UNUSED_FUNCTION = YES; 412 | GCC_WARN_UNUSED_VARIABLE = YES; 413 | IPHONEOS_DEPLOYMENT_TARGET = 9.1; 414 | MTL_ENABLE_DEBUG_INFO = NO; 415 | SDKROOT = iphoneos; 416 | VALIDATE_PRODUCT = YES; 417 | }; 418 | name = Release; 419 | }; 420 | 69773C7F1C0D733E0004E2F6 /* Debug */ = { 421 | isa = XCBuildConfiguration; 422 | buildSettings = { 423 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 424 | INFOPLIST_FILE = UIBezierPath_And_CAShapeLayer/Info.plist; 425 | IPHONEOS_DEPLOYMENT_TARGET = 6.0; 426 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 427 | PRODUCT_BUNDLE_IDENTIFIER = "com.huangyibiao.UIBezierPath-And-CAShapeLayer"; 428 | PRODUCT_NAME = "$(TARGET_NAME)"; 429 | }; 430 | name = Debug; 431 | }; 432 | 69773C801C0D733E0004E2F6 /* Release */ = { 433 | isa = XCBuildConfiguration; 434 | buildSettings = { 435 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 436 | INFOPLIST_FILE = UIBezierPath_And_CAShapeLayer/Info.plist; 437 | IPHONEOS_DEPLOYMENT_TARGET = 6.0; 438 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 439 | PRODUCT_BUNDLE_IDENTIFIER = "com.huangyibiao.UIBezierPath-And-CAShapeLayer"; 440 | PRODUCT_NAME = "$(TARGET_NAME)"; 441 | }; 442 | name = Release; 443 | }; 444 | 69773C821C0D733E0004E2F6 /* Debug */ = { 445 | isa = XCBuildConfiguration; 446 | buildSettings = { 447 | BUNDLE_LOADER = "$(TEST_HOST)"; 448 | INFOPLIST_FILE = UIBezierPath_And_CAShapeLayerTests/Info.plist; 449 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 450 | PRODUCT_BUNDLE_IDENTIFIER = "com.huangyibiao.UIBezierPath-And-CAShapeLayerTests"; 451 | PRODUCT_NAME = "$(TARGET_NAME)"; 452 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/UIBezierPath_And_CAShapeLayer.app/UIBezierPath_And_CAShapeLayer"; 453 | }; 454 | name = Debug; 455 | }; 456 | 69773C831C0D733E0004E2F6 /* Release */ = { 457 | isa = XCBuildConfiguration; 458 | buildSettings = { 459 | BUNDLE_LOADER = "$(TEST_HOST)"; 460 | INFOPLIST_FILE = UIBezierPath_And_CAShapeLayerTests/Info.plist; 461 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 462 | PRODUCT_BUNDLE_IDENTIFIER = "com.huangyibiao.UIBezierPath-And-CAShapeLayerTests"; 463 | PRODUCT_NAME = "$(TARGET_NAME)"; 464 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/UIBezierPath_And_CAShapeLayer.app/UIBezierPath_And_CAShapeLayer"; 465 | }; 466 | name = Release; 467 | }; 468 | 69773C851C0D733E0004E2F6 /* Debug */ = { 469 | isa = XCBuildConfiguration; 470 | buildSettings = { 471 | INFOPLIST_FILE = UIBezierPath_And_CAShapeLayerUITests/Info.plist; 472 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 473 | PRODUCT_BUNDLE_IDENTIFIER = "com.huangyibiao.UIBezierPath-And-CAShapeLayerUITests"; 474 | PRODUCT_NAME = "$(TARGET_NAME)"; 475 | TEST_TARGET_NAME = UIBezierPath_And_CAShapeLayer; 476 | USES_XCTRUNNER = YES; 477 | }; 478 | name = Debug; 479 | }; 480 | 69773C861C0D733E0004E2F6 /* Release */ = { 481 | isa = XCBuildConfiguration; 482 | buildSettings = { 483 | INFOPLIST_FILE = UIBezierPath_And_CAShapeLayerUITests/Info.plist; 484 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 485 | PRODUCT_BUNDLE_IDENTIFIER = "com.huangyibiao.UIBezierPath-And-CAShapeLayerUITests"; 486 | PRODUCT_NAME = "$(TARGET_NAME)"; 487 | TEST_TARGET_NAME = UIBezierPath_And_CAShapeLayer; 488 | USES_XCTRUNNER = YES; 489 | }; 490 | name = Release; 491 | }; 492 | /* End XCBuildConfiguration section */ 493 | 494 | /* Begin XCConfigurationList section */ 495 | 69773C4C1C0D733E0004E2F6 /* Build configuration list for PBXProject "UIBezierPath_And_CAShapeLayer" */ = { 496 | isa = XCConfigurationList; 497 | buildConfigurations = ( 498 | 69773C7C1C0D733E0004E2F6 /* Debug */, 499 | 69773C7D1C0D733E0004E2F6 /* Release */, 500 | ); 501 | defaultConfigurationIsVisible = 0; 502 | defaultConfigurationName = Release; 503 | }; 504 | 69773C7E1C0D733E0004E2F6 /* Build configuration list for PBXNativeTarget "UIBezierPath_And_CAShapeLayer" */ = { 505 | isa = XCConfigurationList; 506 | buildConfigurations = ( 507 | 69773C7F1C0D733E0004E2F6 /* Debug */, 508 | 69773C801C0D733E0004E2F6 /* Release */, 509 | ); 510 | defaultConfigurationIsVisible = 0; 511 | }; 512 | 69773C811C0D733E0004E2F6 /* Build configuration list for PBXNativeTarget "UIBezierPath_And_CAShapeLayerTests" */ = { 513 | isa = XCConfigurationList; 514 | buildConfigurations = ( 515 | 69773C821C0D733E0004E2F6 /* Debug */, 516 | 69773C831C0D733E0004E2F6 /* Release */, 517 | ); 518 | defaultConfigurationIsVisible = 0; 519 | }; 520 | 69773C841C0D733E0004E2F6 /* Build configuration list for PBXNativeTarget "UIBezierPath_And_CAShapeLayerUITests" */ = { 521 | isa = XCConfigurationList; 522 | buildConfigurations = ( 523 | 69773C851C0D733E0004E2F6 /* Debug */, 524 | 69773C861C0D733E0004E2F6 /* Release */, 525 | ); 526 | defaultConfigurationIsVisible = 0; 527 | }; 528 | /* End XCConfigurationList section */ 529 | }; 530 | rootObject = 69773C491C0D733E0004E2F6 /* Project object */; 531 | } 532 | -------------------------------------------------------------------------------- /UIBezierPath_And_CAShapeLayer.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /UIBezierPath_And_CAShapeLayer.xcodeproj/project.xcworkspace/xcuserdata/huangyibiao.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderJackyHuang/UIBezierPathLayerDemos/91b82ae239bac57d0b2c1be453f829d08a5c35ea/UIBezierPath_And_CAShapeLayer.xcodeproj/project.xcworkspace/xcuserdata/huangyibiao.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /UIBezierPath_And_CAShapeLayer.xcodeproj/xcuserdata/huangyibiao.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /UIBezierPath_And_CAShapeLayer.xcodeproj/xcuserdata/huangyibiao.xcuserdatad/xcschemes/UIBezierPath_And_CAShapeLayer.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 | -------------------------------------------------------------------------------- /UIBezierPath_And_CAShapeLayer.xcodeproj/xcuserdata/huangyibiao.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | UIBezierPath_And_CAShapeLayer.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 69773C501C0D733E0004E2F6 16 | 17 | primary 18 | 19 | 20 | 69773C691C0D733E0004E2F6 21 | 22 | primary 23 | 24 | 25 | 69773C741C0D733E0004E2F6 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /UIBezierPath_And_CAShapeLayer/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // UIBezierPath_And_CAShapeLayer 4 | // 5 | // Created by huangyibiao on 15/12/1. 6 | // Copyright © 2015年 huangyibiao. 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 | -------------------------------------------------------------------------------- /UIBezierPath_And_CAShapeLayer/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // UIBezierPath_And_CAShapeLayer 4 | // 5 | // Created by huangyibiao on 15/12/1. 6 | // Copyright © 2015年 huangyibiao. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /UIBezierPath_And_CAShapeLayer/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 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /UIBezierPath_And_CAShapeLayer/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 | -------------------------------------------------------------------------------- /UIBezierPath_And_CAShapeLayer/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /UIBezierPath_And_CAShapeLayer/BezierPathView.h: -------------------------------------------------------------------------------- 1 | // 2 | // BezierPathView.h 3 | // UIBezierPath_And_CAShapeLayer 4 | // 5 | // Created by huangyibiao on 15/12/2. 6 | // Copyright © 2015年 huangyibiao. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef NS_ENUM(NSUInteger, HYBBezierPathType) { 12 | kDefaultPath = 1, // 三角形 13 | kRectPath = 2, // 矩形 14 | kCirclePath = 3,//圆 15 | kOvalPath = 4, // 椭圆 16 | kRoundedRectPath = 5, // 带圆角的矩形 17 | kArcPath = 6, // 弧 18 | kSecondBezierPath = 7, // 二次贝塞尔曲线 19 | kThirdBezierPath = 8 // 三次贝塞尔曲线 20 | }; 21 | 22 | @interface BezierPathView : UIView 23 | 24 | @property (nonatomic, assign) HYBBezierPathType type; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /UIBezierPath_And_CAShapeLayer/BezierPathView.m: -------------------------------------------------------------------------------- 1 | // 2 | // BezierPathView.m 3 | // UIBezierPath_And_CAShapeLayer 4 | // 5 | // Created by huangyibiao on 15/12/2. 6 | // Copyright © 2015年 huangyibiao. All rights reserved. 7 | // 8 | 9 | #import "BezierPathView.h" 10 | 11 | @implementation BezierPathView 12 | 13 | - (void)drawRect:(CGRect)rect { 14 | switch (self.type) { 15 | case kDefaultPath: { 16 | [self drawTrianglePath]; 17 | break; 18 | } 19 | case kRectPath: { 20 | [self drawRectPath]; 21 | break; 22 | } 23 | case kCirclePath: { 24 | [self drawCiclePath]; 25 | break; 26 | } 27 | case kOvalPath: { 28 | [self drawOvalPath]; 29 | break; 30 | } 31 | case kRoundedRectPath: { 32 | [self drawRoundedRectPath]; 33 | break; 34 | } 35 | case kArcPath: { 36 | [self drawARCPath]; 37 | break; 38 | } 39 | case kSecondBezierPath: { 40 | [self drawSecondBezierPath]; 41 | break; 42 | } 43 | case kThirdBezierPath: { 44 | [self drawThirdBezierPath]; 45 | break; 46 | } 47 | default: { 48 | break; 49 | } 50 | } 51 | } 52 | 53 | // 画三角形 54 | - (void)drawTrianglePath { 55 | UIBezierPath *path = [UIBezierPath bezierPath]; 56 | [path moveToPoint:CGPointMake(20, 20)]; 57 | [path addLineToPoint:CGPointMake(self.frame.size.width - 40, 20)]; 58 | [path addLineToPoint:CGPointMake(self.frame.size.width / 2, self.frame.size.height - 20)]; 59 | 60 | // 最后的闭合线是可以通过调用closePath方法来自动生成的,也可以调用-addLineToPoint:方法来添加 61 | // [path addLineToPoint:CGPointMake(20, 20)]; 62 | 63 | [path closePath]; 64 | 65 | // 设置线宽 66 | path.lineWidth = 1.5; 67 | 68 | // 设置填充颜色 69 | UIColor *fillColor = [UIColor greenColor]; 70 | [fillColor set]; 71 | [path fill]; 72 | 73 | // 设置画笔颜色 74 | UIColor *strokeColor = [UIColor blueColor]; 75 | [strokeColor set]; 76 | 77 | // 根据我们设置的各个点连线 78 | [path stroke]; 79 | } 80 | 81 | // 画矩形 82 | - (void)drawRectPath { 83 | UIBezierPath *path = [UIBezierPath bezierPathWithRect:CGRectMake(20, 20, self.frame.size.width - 40, self.frame.size.height - 40)]; 84 | 85 | path.lineWidth = 1.5; 86 | path.lineCapStyle = kCGLineCapRound; 87 | path.lineJoinStyle = kCGLineJoinBevel; 88 | 89 | // 设置填充颜色 90 | UIColor *fillColor = [UIColor greenColor]; 91 | [fillColor set]; 92 | [path fill]; 93 | 94 | // 设置画笔颜色 95 | UIColor *strokeColor = [UIColor blueColor]; 96 | [strokeColor set]; 97 | 98 | // 根据我们设置的各个点连线 99 | [path stroke]; 100 | } 101 | 102 | // 画圆 103 | - (void)drawCiclePath { 104 | // 传的是正方形,因此就可以绘制出圆了 105 | UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(20, 20, self.frame.size.width - 40, self.frame.size.width - 40)]; 106 | 107 | // 设置填充颜色 108 | UIColor *fillColor = [UIColor greenColor]; 109 | [fillColor set]; 110 | [path fill]; 111 | 112 | // 设置画笔颜色 113 | UIColor *strokeColor = [UIColor blueColor]; 114 | [strokeColor set]; 115 | 116 | // 根据我们设置的各个点连线 117 | [path stroke]; 118 | } 119 | 120 | // 画椭圆 121 | - (void)drawOvalPath { 122 | // 传的是不是正方形,因此就可以绘制出椭圆圆了 123 | UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(20, 20, self.frame.size.width - 80, self.frame.size.height - 40)]; 124 | 125 | // 设置填充颜色 126 | UIColor *fillColor = [UIColor greenColor]; 127 | [fillColor set]; 128 | [path fill]; 129 | 130 | // 设置画笔颜色 131 | UIColor *strokeColor = [UIColor blueColor]; 132 | [strokeColor set]; 133 | 134 | // 根据我们设置的各个点连线 135 | [path stroke]; 136 | } 137 | 138 | - (void)drawRoundedRectPath { 139 | // UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(20, 20, self.frame.size.width - 40, self.frame.size.height - 40) cornerRadius:10]; 140 | 141 | UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(20, 20, self.frame.size.width - 40, self.frame.size.height - 40) byRoundingCorners:UIRectCornerTopRight cornerRadii:CGSizeMake(20, 20)]; 142 | // 设置填充颜色 143 | UIColor *fillColor = [UIColor greenColor]; 144 | [fillColor set]; 145 | [path fill]; 146 | 147 | // 设置画笔颜色 148 | UIColor *strokeColor = [UIColor blueColor]; 149 | [strokeColor set]; 150 | 151 | // 根据我们设置的各个点连线 152 | [path stroke]; 153 | } 154 | 155 | #define kDegreesToRadians(degrees) ((pi * degrees)/ 180) 156 | - (void)drawARCPath { 157 | const CGFloat pi = 3.14159265359; 158 | 159 | CGPoint center = CGPointMake(self.frame.size.width / 2, self.frame.size.height / 2); 160 | UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:center 161 | radius:100 162 | startAngle:0 163 | endAngle:kDegreesToRadians(135) 164 | clockwise:YES]; 165 | 166 | path.lineCapStyle = kCGLineCapRound; 167 | path.lineJoinStyle = kCGLineJoinRound; 168 | path.lineWidth = 5.0; 169 | 170 | UIColor *strokeColor = [UIColor redColor]; 171 | [strokeColor set]; 172 | 173 | [path stroke]; 174 | } 175 | 176 | - (void)drawSecondBezierPath { 177 | UIBezierPath *path = [UIBezierPath bezierPath]; 178 | 179 | // 首先设置一个起始点 180 | [path moveToPoint:CGPointMake(20, self.frame.size.height - 100)]; 181 | 182 | // 添加二次曲线 183 | [path addQuadCurveToPoint:CGPointMake(self.frame.size.width - 20, self.frame.size.height - 100) 184 | controlPoint:CGPointMake(self.frame.size.width / 2, 0)]; 185 | 186 | path.lineCapStyle = kCGLineCapRound; 187 | path.lineJoinStyle = kCGLineJoinRound; 188 | path.lineWidth = 5.0; 189 | 190 | UIColor *strokeColor = [UIColor redColor]; 191 | [strokeColor set]; 192 | 193 | [path stroke]; 194 | } 195 | 196 | - (void)drawThirdBezierPath { 197 | UIBezierPath *path = [UIBezierPath bezierPath]; 198 | 199 | // 设置起始端点 200 | [path moveToPoint:CGPointMake(20, 150)]; 201 | 202 | [path addCurveToPoint:CGPointMake(300, 150) 203 | controlPoint1:CGPointMake(160, 0) 204 | controlPoint2:CGPointMake(160, 250)]; 205 | 206 | path.lineCapStyle = kCGLineCapRound; 207 | path.lineJoinStyle = kCGLineJoinRound; 208 | path.lineWidth = 5.0; 209 | 210 | UIColor *strokeColor = [UIColor redColor]; 211 | [strokeColor set]; 212 | 213 | [path stroke]; 214 | } 215 | 216 | @end 217 | -------------------------------------------------------------------------------- /UIBezierPath_And_CAShapeLayer/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /UIBezierPath_And_CAShapeLayer/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // UIBezierPath_And_CAShapeLayer 4 | // 5 | // Created by huangyibiao on 15/12/1. 6 | // Copyright © 2015年 huangyibiao. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /UIBezierPath_And_CAShapeLayer/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // UIBezierPath_And_CAShapeLayer 4 | // 5 | // Created by huangyibiao on 15/12/1. 6 | // Copyright © 2015年 huangyibiao. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "BezierPathView.h" 11 | 12 | @interface ViewController () 13 | 14 | @property (nonatomic, strong) CAShapeLayer *loadingLayer; 15 | @property (nonatomic, strong) NSTimer *timer; 16 | @property (nonatomic, strong) NSArray *animationTypes; 17 | @property (nonatomic, assign) NSUInteger index; 18 | @property (nonatomic, strong) BezierPathView *pathView; 19 | 20 | @end 21 | 22 | @implementation ViewController 23 | 24 | - (void)viewDidLoad { 25 | [super viewDidLoad]; 26 | 27 | self.automaticallyAdjustsScrollViewInsets = NO; 28 | self.edgesForExtendedLayout = UIRectEdgeNone; 29 | 30 | // 如果要测试UIBezierPath,打开注释 31 | [self testBezierPath]; 32 | 33 | // 使用CAShapeLayer与UIBezierPath画圆 34 | // [self drawCircle]; 35 | 36 | // [self drawHalfCircle]; 37 | } 38 | 39 | - (void)drawHalfCircle { 40 | self.loadingLayer = [self drawCircle]; 41 | 42 | // 这个是用于指定画笔的开始与结束点 43 | self.loadingLayer.strokeStart = 0.0; 44 | self.loadingLayer.strokeEnd = 0.75; 45 | 46 | self.timer = [NSTimer scheduledTimerWithTimeInterval:0.1 47 | target:self 48 | selector:@selector(updateCircle) 49 | userInfo:nil 50 | repeats:YES]; 51 | } 52 | 53 | - (void)updateCircle { 54 | if (self.loadingLayer.strokeEnd > 1 && self.loadingLayer.strokeStart < 1) { 55 | self.loadingLayer.strokeStart += 0.1; 56 | } else if (self.loadingLayer.strokeStart == 0) { 57 | self.loadingLayer.strokeEnd += 0.1; 58 | } 59 | 60 | if (self.loadingLayer.strokeEnd == 0) { 61 | self.loadingLayer.strokeStart = 0; 62 | } 63 | 64 | if (self.loadingLayer.strokeStart >= 1 && self.loadingLayer.strokeEnd >= 1) { 65 | self.loadingLayer.strokeStart = 0; 66 | [self.timer invalidate]; 67 | self.timer = nil; 68 | } 69 | } 70 | 71 | - (CAShapeLayer *)drawCircle { 72 | CAShapeLayer *circleLayer = [CAShapeLayer layer]; 73 | // 指定frame,只是为了设置宽度和高度 74 | circleLayer.frame = CGRectMake(0, 0, 200, 200); 75 | // 设置居中显示 76 | circleLayer.position = self.view.center; 77 | // 设置填充颜色 78 | circleLayer.fillColor = [UIColor clearColor].CGColor; 79 | // 设置线宽 80 | circleLayer.lineWidth = 2.0; 81 | // 设置线的颜色 82 | circleLayer.strokeColor = [UIColor redColor].CGColor; 83 | 84 | // 使用UIBezierPath创建路径 85 | CGRect frame = CGRectMake(0, 0, 200, 200); 86 | UIBezierPath *circlePath = [UIBezierPath bezierPathWithOvalInRect:frame]; 87 | 88 | // 设置CAShapeLayer与UIBezierPath关联 89 | circleLayer.path = circlePath.CGPath; 90 | 91 | // 将CAShaperLayer放到某个层上显示 92 | [self.view.layer addSublayer:circleLayer]; 93 | 94 | return circleLayer; 95 | } 96 | 97 | - (void)testBezierPath { 98 | CGFloat height = [UIScreen mainScreen].bounds.size.height; 99 | BezierPathView *v = [[BezierPathView alloc] initWithFrame:CGRectMake(0, 100, self.view.frame.size.width, height - 140 - 64)]; 100 | [self.view addSubview:v]; 101 | v.layer.borderColor = [UIColor redColor].CGColor; 102 | v.layer.borderWidth = 5; 103 | v.backgroundColor = [UIColor whiteColor]; 104 | 105 | v.type = kDefaultPath; 106 | self.index = 0; 107 | 108 | self.animationTypes = @[@(kDefaultPath), 109 | @(kRectPath), 110 | @(kCirclePath), 111 | @(kOvalPath), 112 | @(kRoundedRectPath), 113 | @(kArcPath), 114 | @(kSecondBezierPath)]; 115 | 116 | self.timer = [NSTimer scheduledTimerWithTimeInterval:1 117 | target:self 118 | selector:@selector(updateType) 119 | userInfo:nil 120 | repeats:YES]; 121 | 122 | self.view.layer.borderWidth = 1; 123 | self.view.layer.borderColor = [UIColor blueColor].CGColor; 124 | self.pathView = v; 125 | } 126 | 127 | - (void)updateType { 128 | if (self.index + 1 < self.animationTypes.count) { 129 | self.index ++; 130 | } else { 131 | self.index = 0; 132 | } 133 | 134 | self.pathView.type = [[self.animationTypes objectAtIndex:self.index] intValue]; 135 | [self.pathView setNeedsDisplay]; 136 | } 137 | 138 | @end 139 | -------------------------------------------------------------------------------- /UIBezierPath_And_CAShapeLayer/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // UIBezierPath_And_CAShapeLayer 4 | // 5 | // Created by huangyibiao on 15/12/1. 6 | // Copyright © 2015年 huangyibiao. 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 | -------------------------------------------------------------------------------- /UIBezierPath_And_CAShapeLayerTests/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 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /UIBezierPath_And_CAShapeLayerTests/UIBezierPath_And_CAShapeLayerTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIBezierPath_And_CAShapeLayerTests.m 3 | // UIBezierPath_And_CAShapeLayerTests 4 | // 5 | // Created by huangyibiao on 15/12/1. 6 | // Copyright © 2015年 huangyibiao. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIBezierPath_And_CAShapeLayerTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation UIBezierPath_And_CAShapeLayerTests 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 | -------------------------------------------------------------------------------- /UIBezierPath_And_CAShapeLayerUITests/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 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /UIBezierPath_And_CAShapeLayerUITests/UIBezierPath_And_CAShapeLayerUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIBezierPath_And_CAShapeLayerUITests.m 3 | // UIBezierPath_And_CAShapeLayerUITests 4 | // 5 | // Created by huangyibiao on 15/12/1. 6 | // Copyright © 2015年 huangyibiao. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIBezierPath_And_CAShapeLayerUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation UIBezierPath_And_CAShapeLayerUITests 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 | --------------------------------------------------------------------------------