├── LoadingAnimation.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ └── LoadingAnimation.xccheckout │ └── xcuserdata │ │ └── he15his.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── he15his.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── LoadingAnimation.xcscheme │ └── xcschememanagement.plist ├── LoadingAnimation ├── AppDelegate.h ├── AppDelegate.m ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard ├── Images.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Info.plist ├── SinLoadingView.h ├── SinLoadingView.m ├── SnakeLoadingView.h ├── SnakeLoadingView.m ├── UIColor+More.h ├── UIColor+More.m ├── ViewController.h ├── ViewController.m └── main.m ├── LoadingAnimationTests ├── Info.plist └── LoadingAnimationTests.m ├── README.md ├── UI.Animation.uisheji.com199119910.gif └── ui.animatton.uisheji.com_.gif-0392.gif /LoadingAnimation.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 02D7D7631B1FEEFB00D2AC52 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 02D7D7621B1FEEFB00D2AC52 /* main.m */; }; 11 | 02D7D7661B1FEEFB00D2AC52 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 02D7D7651B1FEEFB00D2AC52 /* AppDelegate.m */; }; 12 | 02D7D7691B1FEEFB00D2AC52 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 02D7D7681B1FEEFB00D2AC52 /* ViewController.m */; }; 13 | 02D7D76C1B1FEEFB00D2AC52 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 02D7D76A1B1FEEFB00D2AC52 /* Main.storyboard */; }; 14 | 02D7D76E1B1FEEFB00D2AC52 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 02D7D76D1B1FEEFB00D2AC52 /* Images.xcassets */; }; 15 | 02D7D7711B1FEEFB00D2AC52 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 02D7D76F1B1FEEFB00D2AC52 /* LaunchScreen.xib */; }; 16 | 02D7D77D1B1FEEFB00D2AC52 /* LoadingAnimationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 02D7D77C1B1FEEFB00D2AC52 /* LoadingAnimationTests.m */; }; 17 | 02D7D7881B1FEF3D00D2AC52 /* SinLoadingView.m in Sources */ = {isa = PBXBuildFile; fileRef = 02D7D7871B1FEF3D00D2AC52 /* SinLoadingView.m */; }; 18 | 02D7D78B1B1FEFFB00D2AC52 /* UIColor+More.m in Sources */ = {isa = PBXBuildFile; fileRef = 02D7D78A1B1FEFFB00D2AC52 /* UIColor+More.m */; }; 19 | 02D7D78E1B20058300D2AC52 /* SnakeLoadingView.m in Sources */ = {isa = PBXBuildFile; fileRef = 02D7D78D1B20058300D2AC52 /* SnakeLoadingView.m */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXContainerItemProxy section */ 23 | 02D7D7771B1FEEFB00D2AC52 /* PBXContainerItemProxy */ = { 24 | isa = PBXContainerItemProxy; 25 | containerPortal = 02D7D7551B1FEEFB00D2AC52 /* Project object */; 26 | proxyType = 1; 27 | remoteGlobalIDString = 02D7D75C1B1FEEFB00D2AC52; 28 | remoteInfo = LoadingAnimation; 29 | }; 30 | /* End PBXContainerItemProxy section */ 31 | 32 | /* Begin PBXFileReference section */ 33 | 02D7D75D1B1FEEFB00D2AC52 /* LoadingAnimation.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LoadingAnimation.app; sourceTree = BUILT_PRODUCTS_DIR; }; 34 | 02D7D7611B1FEEFB00D2AC52 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 35 | 02D7D7621B1FEEFB00D2AC52 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 36 | 02D7D7641B1FEEFB00D2AC52 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 37 | 02D7D7651B1FEEFB00D2AC52 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 38 | 02D7D7671B1FEEFB00D2AC52 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 39 | 02D7D7681B1FEEFB00D2AC52 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 40 | 02D7D76B1B1FEEFB00D2AC52 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 41 | 02D7D76D1B1FEEFB00D2AC52 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 42 | 02D7D7701B1FEEFB00D2AC52 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 43 | 02D7D7761B1FEEFB00D2AC52 /* LoadingAnimationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = LoadingAnimationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 44 | 02D7D77B1B1FEEFB00D2AC52 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 45 | 02D7D77C1B1FEEFB00D2AC52 /* LoadingAnimationTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LoadingAnimationTests.m; sourceTree = ""; }; 46 | 02D7D7861B1FEF3D00D2AC52 /* SinLoadingView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SinLoadingView.h; sourceTree = ""; }; 47 | 02D7D7871B1FEF3D00D2AC52 /* SinLoadingView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SinLoadingView.m; sourceTree = ""; }; 48 | 02D7D7891B1FEFFB00D2AC52 /* UIColor+More.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIColor+More.h"; sourceTree = ""; }; 49 | 02D7D78A1B1FEFFB00D2AC52 /* UIColor+More.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIColor+More.m"; sourceTree = ""; }; 50 | 02D7D78C1B20058300D2AC52 /* SnakeLoadingView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SnakeLoadingView.h; sourceTree = ""; }; 51 | 02D7D78D1B20058300D2AC52 /* SnakeLoadingView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SnakeLoadingView.m; sourceTree = ""; }; 52 | /* End PBXFileReference section */ 53 | 54 | /* Begin PBXFrameworksBuildPhase section */ 55 | 02D7D75A1B1FEEFB00D2AC52 /* Frameworks */ = { 56 | isa = PBXFrameworksBuildPhase; 57 | buildActionMask = 2147483647; 58 | files = ( 59 | ); 60 | runOnlyForDeploymentPostprocessing = 0; 61 | }; 62 | 02D7D7731B1FEEFB00D2AC52 /* Frameworks */ = { 63 | isa = PBXFrameworksBuildPhase; 64 | buildActionMask = 2147483647; 65 | files = ( 66 | ); 67 | runOnlyForDeploymentPostprocessing = 0; 68 | }; 69 | /* End PBXFrameworksBuildPhase section */ 70 | 71 | /* Begin PBXGroup section */ 72 | 02D7D7541B1FEEFB00D2AC52 = { 73 | isa = PBXGroup; 74 | children = ( 75 | 02D7D75F1B1FEEFB00D2AC52 /* LoadingAnimation */, 76 | 02D7D7791B1FEEFB00D2AC52 /* LoadingAnimationTests */, 77 | 02D7D75E1B1FEEFB00D2AC52 /* Products */, 78 | ); 79 | sourceTree = ""; 80 | }; 81 | 02D7D75E1B1FEEFB00D2AC52 /* Products */ = { 82 | isa = PBXGroup; 83 | children = ( 84 | 02D7D75D1B1FEEFB00D2AC52 /* LoadingAnimation.app */, 85 | 02D7D7761B1FEEFB00D2AC52 /* LoadingAnimationTests.xctest */, 86 | ); 87 | name = Products; 88 | sourceTree = ""; 89 | }; 90 | 02D7D75F1B1FEEFB00D2AC52 /* LoadingAnimation */ = { 91 | isa = PBXGroup; 92 | children = ( 93 | 02D7D7641B1FEEFB00D2AC52 /* AppDelegate.h */, 94 | 02D7D7651B1FEEFB00D2AC52 /* AppDelegate.m */, 95 | 02D7D7671B1FEEFB00D2AC52 /* ViewController.h */, 96 | 02D7D7681B1FEEFB00D2AC52 /* ViewController.m */, 97 | 02D7D7861B1FEF3D00D2AC52 /* SinLoadingView.h */, 98 | 02D7D7871B1FEF3D00D2AC52 /* SinLoadingView.m */, 99 | 02D7D78C1B20058300D2AC52 /* SnakeLoadingView.h */, 100 | 02D7D78D1B20058300D2AC52 /* SnakeLoadingView.m */, 101 | 02D7D76A1B1FEEFB00D2AC52 /* Main.storyboard */, 102 | 02D7D76D1B1FEEFB00D2AC52 /* Images.xcassets */, 103 | 02D7D76F1B1FEEFB00D2AC52 /* LaunchScreen.xib */, 104 | 02D7D7891B1FEFFB00D2AC52 /* UIColor+More.h */, 105 | 02D7D78A1B1FEFFB00D2AC52 /* UIColor+More.m */, 106 | 02D7D7601B1FEEFB00D2AC52 /* Supporting Files */, 107 | ); 108 | path = LoadingAnimation; 109 | sourceTree = ""; 110 | }; 111 | 02D7D7601B1FEEFB00D2AC52 /* Supporting Files */ = { 112 | isa = PBXGroup; 113 | children = ( 114 | 02D7D7611B1FEEFB00D2AC52 /* Info.plist */, 115 | 02D7D7621B1FEEFB00D2AC52 /* main.m */, 116 | ); 117 | name = "Supporting Files"; 118 | sourceTree = ""; 119 | }; 120 | 02D7D7791B1FEEFB00D2AC52 /* LoadingAnimationTests */ = { 121 | isa = PBXGroup; 122 | children = ( 123 | 02D7D77C1B1FEEFB00D2AC52 /* LoadingAnimationTests.m */, 124 | 02D7D77A1B1FEEFB00D2AC52 /* Supporting Files */, 125 | ); 126 | path = LoadingAnimationTests; 127 | sourceTree = ""; 128 | }; 129 | 02D7D77A1B1FEEFB00D2AC52 /* Supporting Files */ = { 130 | isa = PBXGroup; 131 | children = ( 132 | 02D7D77B1B1FEEFB00D2AC52 /* Info.plist */, 133 | ); 134 | name = "Supporting Files"; 135 | sourceTree = ""; 136 | }; 137 | /* End PBXGroup section */ 138 | 139 | /* Begin PBXNativeTarget section */ 140 | 02D7D75C1B1FEEFB00D2AC52 /* LoadingAnimation */ = { 141 | isa = PBXNativeTarget; 142 | buildConfigurationList = 02D7D7801B1FEEFB00D2AC52 /* Build configuration list for PBXNativeTarget "LoadingAnimation" */; 143 | buildPhases = ( 144 | 02D7D7591B1FEEFB00D2AC52 /* Sources */, 145 | 02D7D75A1B1FEEFB00D2AC52 /* Frameworks */, 146 | 02D7D75B1B1FEEFB00D2AC52 /* Resources */, 147 | ); 148 | buildRules = ( 149 | ); 150 | dependencies = ( 151 | ); 152 | name = LoadingAnimation; 153 | productName = LoadingAnimation; 154 | productReference = 02D7D75D1B1FEEFB00D2AC52 /* LoadingAnimation.app */; 155 | productType = "com.apple.product-type.application"; 156 | }; 157 | 02D7D7751B1FEEFB00D2AC52 /* LoadingAnimationTests */ = { 158 | isa = PBXNativeTarget; 159 | buildConfigurationList = 02D7D7831B1FEEFB00D2AC52 /* Build configuration list for PBXNativeTarget "LoadingAnimationTests" */; 160 | buildPhases = ( 161 | 02D7D7721B1FEEFB00D2AC52 /* Sources */, 162 | 02D7D7731B1FEEFB00D2AC52 /* Frameworks */, 163 | 02D7D7741B1FEEFB00D2AC52 /* Resources */, 164 | ); 165 | buildRules = ( 166 | ); 167 | dependencies = ( 168 | 02D7D7781B1FEEFB00D2AC52 /* PBXTargetDependency */, 169 | ); 170 | name = LoadingAnimationTests; 171 | productName = LoadingAnimationTests; 172 | productReference = 02D7D7761B1FEEFB00D2AC52 /* LoadingAnimationTests.xctest */; 173 | productType = "com.apple.product-type.bundle.unit-test"; 174 | }; 175 | /* End PBXNativeTarget section */ 176 | 177 | /* Begin PBXProject section */ 178 | 02D7D7551B1FEEFB00D2AC52 /* Project object */ = { 179 | isa = PBXProject; 180 | attributes = { 181 | LastUpgradeCheck = 0630; 182 | ORGANIZATIONNAME = he15his; 183 | TargetAttributes = { 184 | 02D7D75C1B1FEEFB00D2AC52 = { 185 | CreatedOnToolsVersion = 6.3.2; 186 | }; 187 | 02D7D7751B1FEEFB00D2AC52 = { 188 | CreatedOnToolsVersion = 6.3.2; 189 | TestTargetID = 02D7D75C1B1FEEFB00D2AC52; 190 | }; 191 | }; 192 | }; 193 | buildConfigurationList = 02D7D7581B1FEEFB00D2AC52 /* Build configuration list for PBXProject "LoadingAnimation" */; 194 | compatibilityVersion = "Xcode 3.2"; 195 | developmentRegion = English; 196 | hasScannedForEncodings = 0; 197 | knownRegions = ( 198 | en, 199 | Base, 200 | ); 201 | mainGroup = 02D7D7541B1FEEFB00D2AC52; 202 | productRefGroup = 02D7D75E1B1FEEFB00D2AC52 /* Products */; 203 | projectDirPath = ""; 204 | projectRoot = ""; 205 | targets = ( 206 | 02D7D75C1B1FEEFB00D2AC52 /* LoadingAnimation */, 207 | 02D7D7751B1FEEFB00D2AC52 /* LoadingAnimationTests */, 208 | ); 209 | }; 210 | /* End PBXProject section */ 211 | 212 | /* Begin PBXResourcesBuildPhase section */ 213 | 02D7D75B1B1FEEFB00D2AC52 /* Resources */ = { 214 | isa = PBXResourcesBuildPhase; 215 | buildActionMask = 2147483647; 216 | files = ( 217 | 02D7D76C1B1FEEFB00D2AC52 /* Main.storyboard in Resources */, 218 | 02D7D7711B1FEEFB00D2AC52 /* LaunchScreen.xib in Resources */, 219 | 02D7D76E1B1FEEFB00D2AC52 /* Images.xcassets in Resources */, 220 | ); 221 | runOnlyForDeploymentPostprocessing = 0; 222 | }; 223 | 02D7D7741B1FEEFB00D2AC52 /* Resources */ = { 224 | isa = PBXResourcesBuildPhase; 225 | buildActionMask = 2147483647; 226 | files = ( 227 | ); 228 | runOnlyForDeploymentPostprocessing = 0; 229 | }; 230 | /* End PBXResourcesBuildPhase section */ 231 | 232 | /* Begin PBXSourcesBuildPhase section */ 233 | 02D7D7591B1FEEFB00D2AC52 /* Sources */ = { 234 | isa = PBXSourcesBuildPhase; 235 | buildActionMask = 2147483647; 236 | files = ( 237 | 02D7D78E1B20058300D2AC52 /* SnakeLoadingView.m in Sources */, 238 | 02D7D7691B1FEEFB00D2AC52 /* ViewController.m in Sources */, 239 | 02D7D7661B1FEEFB00D2AC52 /* AppDelegate.m in Sources */, 240 | 02D7D7881B1FEF3D00D2AC52 /* SinLoadingView.m in Sources */, 241 | 02D7D7631B1FEEFB00D2AC52 /* main.m in Sources */, 242 | 02D7D78B1B1FEFFB00D2AC52 /* UIColor+More.m in Sources */, 243 | ); 244 | runOnlyForDeploymentPostprocessing = 0; 245 | }; 246 | 02D7D7721B1FEEFB00D2AC52 /* Sources */ = { 247 | isa = PBXSourcesBuildPhase; 248 | buildActionMask = 2147483647; 249 | files = ( 250 | 02D7D77D1B1FEEFB00D2AC52 /* LoadingAnimationTests.m in Sources */, 251 | ); 252 | runOnlyForDeploymentPostprocessing = 0; 253 | }; 254 | /* End PBXSourcesBuildPhase section */ 255 | 256 | /* Begin PBXTargetDependency section */ 257 | 02D7D7781B1FEEFB00D2AC52 /* PBXTargetDependency */ = { 258 | isa = PBXTargetDependency; 259 | target = 02D7D75C1B1FEEFB00D2AC52 /* LoadingAnimation */; 260 | targetProxy = 02D7D7771B1FEEFB00D2AC52 /* PBXContainerItemProxy */; 261 | }; 262 | /* End PBXTargetDependency section */ 263 | 264 | /* Begin PBXVariantGroup section */ 265 | 02D7D76A1B1FEEFB00D2AC52 /* Main.storyboard */ = { 266 | isa = PBXVariantGroup; 267 | children = ( 268 | 02D7D76B1B1FEEFB00D2AC52 /* Base */, 269 | ); 270 | name = Main.storyboard; 271 | sourceTree = ""; 272 | }; 273 | 02D7D76F1B1FEEFB00D2AC52 /* LaunchScreen.xib */ = { 274 | isa = PBXVariantGroup; 275 | children = ( 276 | 02D7D7701B1FEEFB00D2AC52 /* Base */, 277 | ); 278 | name = LaunchScreen.xib; 279 | sourceTree = ""; 280 | }; 281 | /* End PBXVariantGroup section */ 282 | 283 | /* Begin XCBuildConfiguration section */ 284 | 02D7D77E1B1FEEFB00D2AC52 /* Debug */ = { 285 | isa = XCBuildConfiguration; 286 | buildSettings = { 287 | ALWAYS_SEARCH_USER_PATHS = NO; 288 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 289 | CLANG_CXX_LIBRARY = "libc++"; 290 | CLANG_ENABLE_MODULES = YES; 291 | CLANG_ENABLE_OBJC_ARC = YES; 292 | CLANG_WARN_BOOL_CONVERSION = YES; 293 | CLANG_WARN_CONSTANT_CONVERSION = YES; 294 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 295 | CLANG_WARN_EMPTY_BODY = YES; 296 | CLANG_WARN_ENUM_CONVERSION = YES; 297 | CLANG_WARN_INT_CONVERSION = YES; 298 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 299 | CLANG_WARN_UNREACHABLE_CODE = YES; 300 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 301 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 302 | COPY_PHASE_STRIP = NO; 303 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 304 | ENABLE_STRICT_OBJC_MSGSEND = YES; 305 | GCC_C_LANGUAGE_STANDARD = gnu99; 306 | GCC_DYNAMIC_NO_PIC = NO; 307 | GCC_NO_COMMON_BLOCKS = YES; 308 | GCC_OPTIMIZATION_LEVEL = 0; 309 | GCC_PREPROCESSOR_DEFINITIONS = ( 310 | "DEBUG=1", 311 | "$(inherited)", 312 | ); 313 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 314 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 315 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 316 | GCC_WARN_UNDECLARED_SELECTOR = YES; 317 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 318 | GCC_WARN_UNUSED_FUNCTION = YES; 319 | GCC_WARN_UNUSED_VARIABLE = YES; 320 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 321 | MTL_ENABLE_DEBUG_INFO = YES; 322 | ONLY_ACTIVE_ARCH = YES; 323 | SDKROOT = iphoneos; 324 | }; 325 | name = Debug; 326 | }; 327 | 02D7D77F1B1FEEFB00D2AC52 /* Release */ = { 328 | isa = XCBuildConfiguration; 329 | buildSettings = { 330 | ALWAYS_SEARCH_USER_PATHS = NO; 331 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 332 | CLANG_CXX_LIBRARY = "libc++"; 333 | CLANG_ENABLE_MODULES = YES; 334 | CLANG_ENABLE_OBJC_ARC = YES; 335 | CLANG_WARN_BOOL_CONVERSION = YES; 336 | CLANG_WARN_CONSTANT_CONVERSION = YES; 337 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 338 | CLANG_WARN_EMPTY_BODY = YES; 339 | CLANG_WARN_ENUM_CONVERSION = YES; 340 | CLANG_WARN_INT_CONVERSION = YES; 341 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 342 | CLANG_WARN_UNREACHABLE_CODE = YES; 343 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 344 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 345 | COPY_PHASE_STRIP = NO; 346 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 347 | ENABLE_NS_ASSERTIONS = NO; 348 | ENABLE_STRICT_OBJC_MSGSEND = YES; 349 | GCC_C_LANGUAGE_STANDARD = gnu99; 350 | GCC_NO_COMMON_BLOCKS = YES; 351 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 352 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 353 | GCC_WARN_UNDECLARED_SELECTOR = YES; 354 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 355 | GCC_WARN_UNUSED_FUNCTION = YES; 356 | GCC_WARN_UNUSED_VARIABLE = YES; 357 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 358 | MTL_ENABLE_DEBUG_INFO = NO; 359 | SDKROOT = iphoneos; 360 | VALIDATE_PRODUCT = YES; 361 | }; 362 | name = Release; 363 | }; 364 | 02D7D7811B1FEEFB00D2AC52 /* Debug */ = { 365 | isa = XCBuildConfiguration; 366 | buildSettings = { 367 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 368 | INFOPLIST_FILE = LoadingAnimation/Info.plist; 369 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 370 | PRODUCT_NAME = "$(TARGET_NAME)"; 371 | }; 372 | name = Debug; 373 | }; 374 | 02D7D7821B1FEEFB00D2AC52 /* Release */ = { 375 | isa = XCBuildConfiguration; 376 | buildSettings = { 377 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 378 | INFOPLIST_FILE = LoadingAnimation/Info.plist; 379 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 380 | PRODUCT_NAME = "$(TARGET_NAME)"; 381 | }; 382 | name = Release; 383 | }; 384 | 02D7D7841B1FEEFB00D2AC52 /* Debug */ = { 385 | isa = XCBuildConfiguration; 386 | buildSettings = { 387 | BUNDLE_LOADER = "$(TEST_HOST)"; 388 | FRAMEWORK_SEARCH_PATHS = ( 389 | "$(SDKROOT)/Developer/Library/Frameworks", 390 | "$(inherited)", 391 | ); 392 | GCC_PREPROCESSOR_DEFINITIONS = ( 393 | "DEBUG=1", 394 | "$(inherited)", 395 | ); 396 | INFOPLIST_FILE = LoadingAnimationTests/Info.plist; 397 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 398 | PRODUCT_NAME = "$(TARGET_NAME)"; 399 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/LoadingAnimation.app/LoadingAnimation"; 400 | }; 401 | name = Debug; 402 | }; 403 | 02D7D7851B1FEEFB00D2AC52 /* Release */ = { 404 | isa = XCBuildConfiguration; 405 | buildSettings = { 406 | BUNDLE_LOADER = "$(TEST_HOST)"; 407 | FRAMEWORK_SEARCH_PATHS = ( 408 | "$(SDKROOT)/Developer/Library/Frameworks", 409 | "$(inherited)", 410 | ); 411 | INFOPLIST_FILE = LoadingAnimationTests/Info.plist; 412 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 413 | PRODUCT_NAME = "$(TARGET_NAME)"; 414 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/LoadingAnimation.app/LoadingAnimation"; 415 | }; 416 | name = Release; 417 | }; 418 | /* End XCBuildConfiguration section */ 419 | 420 | /* Begin XCConfigurationList section */ 421 | 02D7D7581B1FEEFB00D2AC52 /* Build configuration list for PBXProject "LoadingAnimation" */ = { 422 | isa = XCConfigurationList; 423 | buildConfigurations = ( 424 | 02D7D77E1B1FEEFB00D2AC52 /* Debug */, 425 | 02D7D77F1B1FEEFB00D2AC52 /* Release */, 426 | ); 427 | defaultConfigurationIsVisible = 0; 428 | defaultConfigurationName = Release; 429 | }; 430 | 02D7D7801B1FEEFB00D2AC52 /* Build configuration list for PBXNativeTarget "LoadingAnimation" */ = { 431 | isa = XCConfigurationList; 432 | buildConfigurations = ( 433 | 02D7D7811B1FEEFB00D2AC52 /* Debug */, 434 | 02D7D7821B1FEEFB00D2AC52 /* Release */, 435 | ); 436 | defaultConfigurationIsVisible = 0; 437 | }; 438 | 02D7D7831B1FEEFB00D2AC52 /* Build configuration list for PBXNativeTarget "LoadingAnimationTests" */ = { 439 | isa = XCConfigurationList; 440 | buildConfigurations = ( 441 | 02D7D7841B1FEEFB00D2AC52 /* Debug */, 442 | 02D7D7851B1FEEFB00D2AC52 /* Release */, 443 | ); 444 | defaultConfigurationIsVisible = 0; 445 | }; 446 | /* End XCConfigurationList section */ 447 | }; 448 | rootObject = 02D7D7551B1FEEFB00D2AC52 /* Project object */; 449 | } 450 | -------------------------------------------------------------------------------- /LoadingAnimation.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /LoadingAnimation.xcodeproj/project.xcworkspace/xcshareddata/LoadingAnimation.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | FBFA5F54-3901-49D6-BF51-C78F92BBC455 9 | IDESourceControlProjectName 10 | LoadingAnimation 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 7AE5C79D2C279FAB85B0119F4AE085055DAE1046 14 | https://github.com/he15his/LoadingAnimation.git 15 | 16 | IDESourceControlProjectPath 17 | LoadingAnimation.xcodeproj 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 7AE5C79D2C279FAB85B0119F4AE085055DAE1046 21 | ../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/he15his/LoadingAnimation.git 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | 7AE5C79D2C279FAB85B0119F4AE085055DAE1046 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 7AE5C79D2C279FAB85B0119F4AE085055DAE1046 36 | IDESourceControlWCCName 37 | LoadingAnimation 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /LoadingAnimation.xcodeproj/project.xcworkspace/xcuserdata/he15his.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/he15his/LoadingAnimation/71ca1133c411c9db1ef01edd4c6ed189b27c08e1/LoadingAnimation.xcodeproj/project.xcworkspace/xcuserdata/he15his.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /LoadingAnimation.xcodeproj/xcuserdata/he15his.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /LoadingAnimation.xcodeproj/xcuserdata/he15his.xcuserdatad/xcschemes/LoadingAnimation.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 75 | 77 | 83 | 84 | 85 | 86 | 87 | 88 | 94 | 96 | 102 | 103 | 104 | 105 | 107 | 108 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /LoadingAnimation.xcodeproj/xcuserdata/he15his.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | LoadingAnimation.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 02D7D75C1B1FEEFB00D2AC52 16 | 17 | primary 18 | 19 | 20 | 02D7D7751B1FEEFB00D2AC52 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /LoadingAnimation/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // LoadingAnimation 4 | // 5 | // Created by he15his on 15/6/4. 6 | // Copyright (c) 2015年 he15his. 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 | -------------------------------------------------------------------------------- /LoadingAnimation/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // LoadingAnimation 4 | // 5 | // Created by he15his on 15/6/4. 6 | // Copyright (c) 2015年 he15his. 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 | -------------------------------------------------------------------------------- /LoadingAnimation/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /LoadingAnimation/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 | -------------------------------------------------------------------------------- /LoadingAnimation/Images.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 | } -------------------------------------------------------------------------------- /LoadingAnimation/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | he15his.$(PRODUCT_NAME:rfc1034identifier) 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 | -------------------------------------------------------------------------------- /LoadingAnimation/SinLoadingView.h: -------------------------------------------------------------------------------- 1 | // 2 | // SinLoadingView.h 3 | // LoadingAnimation 4 | // 5 | // Created by he15his on 15/6/4. 6 | // Copyright (c) 2015年 he15his. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SinLoadingView : UIView 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /LoadingAnimation/SinLoadingView.m: -------------------------------------------------------------------------------- 1 | // 2 | // SinLoadingView.m 3 | // LoadingAnimation 4 | // 5 | // Created by he15his on 15/6/4. 6 | // Copyright (c) 2015年 he15his. All rights reserved. 7 | // 8 | 9 | #import "SinLoadingView.h" 10 | 11 | #define kPointNumber 15 12 | #define kPointSpace 1.0 13 | 14 | @implementation SinLoadingView { 15 | CAShapeLayer *shapeLayer; 16 | } 17 | 18 | - (instancetype)initWithFrame:(CGRect)frame { 19 | self = [super initWithFrame:frame]; 20 | if (self) { 21 | shapeLayer = [CAShapeLayer layer]; 22 | shapeLayer.frame = frame; 23 | shapeLayer.fillColor = [UIColor whiteColor].CGColor; 24 | [self.layer addSublayer:shapeLayer]; 25 | 26 | [self starAnimation]; 27 | } 28 | return self; 29 | } 30 | 31 | - (UIBezierPath *)sinPathWithProgress:(CGFloat)progress { 32 | CGRect frame = self.frame; 33 | UIBezierPath *path = [UIBezierPath bezierPath]; 34 | CGFloat radius = (CGRectGetWidth(frame) - (kPointNumber - 1) * kPointSpace) / (CGFloat)kPointNumber / 2.0; 35 | 36 | for (NSInteger i = 0; i < kPointNumber; i++) { 37 | CGFloat x = radius + i * (kPointSpace + radius*2); 38 | CGFloat y = CGRectGetHeight(frame) / 2.0 * (sin(i / (kPointNumber - 1.0) * (M_PI * 2) + progress * M_PI * 2) + 1); 39 | [path moveToPoint:CGPointMake(x, y)]; 40 | [path addArcWithCenter:CGPointMake(x, y) radius:radius startAngle:0 endAngle:M_PI*2 clockwise:YES]; 41 | } 42 | return path; 43 | } 44 | 45 | - (void)starAnimation { 46 | CADisplayLink *link = [CADisplayLink displayLinkWithTarget:self selector:@selector(progressValueChange)]; 47 | [link addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes]; 48 | } 49 | 50 | - (void)progressValueChange { 51 | static CGFloat progress = 0.0; 52 | progress += 0.015; 53 | 54 | if (progress > 1) { 55 | progress = 0; 56 | } 57 | shapeLayer.path = [self sinPathWithProgress:progress].CGPath; 58 | } 59 | @end 60 | -------------------------------------------------------------------------------- /LoadingAnimation/SnakeLoadingView.h: -------------------------------------------------------------------------------- 1 | // 2 | // SnakeLoadingView.h 3 | // LoadingAnimation 4 | // 5 | // Created by he15his on 15/6/4. 6 | // Copyright (c) 2015年 he15his. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SnakeLoadingView : UIView 12 | @property (nonatomic, assign) CGFloat lineWidth; 13 | 14 | - (void)stopAnimation; 15 | - (void)starAnimation; 16 | @end 17 | -------------------------------------------------------------------------------- /LoadingAnimation/SnakeLoadingView.m: -------------------------------------------------------------------------------- 1 | // 2 | // SnakeLoadingView.m 3 | // LoadingAnimation 4 | // 5 | // Created by he15his on 15/6/4. 6 | // Copyright (c) 2015年 he15his. All rights reserved. 7 | // 8 | 9 | #import "SnakeLoadingView.h" 10 | #import "UIColor+More.h" 11 | 12 | @implementation SnakeLoadingView{ 13 | CAShapeLayer *shapeLayer1; 14 | CAShapeLayer *shapeLayer2; 15 | CAGradientLayer *gradientLayer; 16 | CGFloat radius; //半圆的半径 17 | 18 | } 19 | 20 | - (instancetype)initWithFrame:(CGRect)frame { 21 | self = [super initWithFrame:frame]; 22 | if (self) { 23 | radius = CGRectGetWidth(self.frame) / 8.0; 24 | _lineWidth = radius; 25 | 26 | //渐变layer 27 | gradientLayer = [CAGradientLayer layer]; 28 | gradientLayer.frame = self.bounds; 29 | [gradientLayer setColors:[NSArray arrayWithObjects:(id)[[UIColor colorWithString:@"#7bea93"] CGColor],(id)[[UIColor colorWithString:@"#76e7c9"] CGColor], nil]]; 30 | [gradientLayer setStartPoint:CGPointMake(0, 0.5)]; 31 | [gradientLayer setEndPoint:CGPointMake(1, 0.5)]; 32 | [self.layer addSublayer:gradientLayer]; 33 | 34 | //图形layer 35 | CALayer *layer = [CALayer layer]; 36 | layer.frame = self.bounds; 37 | shapeLayer1 = [self shapeLayer]; 38 | shapeLayer2 = [self shapeLayer]; 39 | [layer addSublayer:shapeLayer1]; 40 | [layer addSublayer:shapeLayer2]; 41 | 42 | gradientLayer.mask = layer; 43 | } 44 | return self; 45 | } 46 | 47 | - (CAShapeLayer *)shapeLayer { 48 | CAShapeLayer *shapeLayer = [CAShapeLayer layer]; 49 | shapeLayer.frame = self.frame; 50 | shapeLayer.fillColor = [UIColor clearColor].CGColor; 51 | shapeLayer.lineWidth = _lineWidth; 52 | shapeLayer.strokeColor = [UIColor redColor].CGColor; 53 | shapeLayer.lineCap = kCALineCapRound; 54 | shapeLayer.lineJoin = kCALineJoinRound; 55 | return shapeLayer; 56 | } 57 | 58 | //绘制图形路径 59 | - (UIBezierPath *)sinPathWithProgress:(CGFloat)progress offsetX:(CGFloat)offsetX{ 60 | 61 | CGRect frame = self.frame; 62 | UIBezierPath *path = [UIBezierPath bezierPath]; 63 | 64 | CGFloat angle = 0; 65 | CGPoint point = CGPointMake(0, 0); 66 | CGFloat lineHeight = 0.0; 67 | CGFloat lineHeight_Max = CGRectGetHeight(frame) - 2 * radius - _lineWidth; 68 | CGFloat girth = (lineHeight_Max) * 3 + M_PI * radius * 3; 69 | BOOL clockwise = NO; 70 | BOOL isLine = NO; 71 | 72 | if (progress < 0.25) { 73 | isLine = NO; 74 | clockwise = YES; 75 | angle = M_PI + M_PI * progress / 0.25; 76 | 77 | if (progress > 0.125) { 78 | CGFloat angle1 = angle - M_PI_2 * 3; 79 | point.x = -radius * sin(angle1); 80 | }else{ 81 | CGFloat angle1 = angle - M_PI; 82 | point.x = radius * cos(angle1); 83 | } 84 | point.x -= radius; 85 | point.y = radius; 86 | 87 | }else if (progress < 0.5) { 88 | isLine = YES; 89 | clockwise = YES; 90 | lineHeight = lineHeight_Max * (1 - (progress - 0.25) / 0.25); 91 | point.y = CGRectGetHeight(frame) - lineHeight - radius; 92 | }else if (progress < 0.75) { 93 | isLine = NO; 94 | clockwise = NO; 95 | angle = M_PI - M_PI * (progress - 0.5) / 0.25; 96 | 97 | if (progress > 0.625) { 98 | CGFloat angle1 = angle; 99 | point.x = -radius * cos(angle1); 100 | 101 | }else{ 102 | CGFloat angle1 = angle - M_PI_2; 103 | point.x = radius * sin(angle1); 104 | } 105 | point.x -= radius; 106 | point.y = CGRectGetHeight(frame) - radius; 107 | 108 | }else { 109 | isLine = YES; 110 | clockwise = NO; 111 | lineHeight = lineHeight_Max * (1 - (progress - 0.75) / 0.25); 112 | point.y = lineHeight + radius; 113 | } 114 | 115 | point.x += offsetX; 116 | 117 | point.x += _lineWidth/2.0; 118 | point.y += _lineWidth/2.0; 119 | 120 | if (isLine) { 121 | [path moveToPoint:point]; 122 | } 123 | 124 | CGFloat lineLenth = 0.0; 125 | BOOL filish = NO; 126 | 127 | do { 128 | if (isLine) { 129 | 130 | if (lineLenth + lineHeight >= girth) { 131 | lineHeight = girth - lineLenth; 132 | filish = YES; 133 | } 134 | 135 | lineLenth += lineHeight; 136 | 137 | if (!clockwise) { 138 | point.y -= lineHeight; 139 | }else { 140 | point.y += lineHeight; 141 | } 142 | [path addLineToPoint:point]; 143 | angle = M_PI; 144 | clockwise = !clockwise; 145 | }else { 146 | 147 | CGFloat angleGirth; 148 | CGFloat endAngle = 0; 149 | 150 | if (!clockwise) { 151 | angleGirth = radius * angle; 152 | 153 | if (lineLenth + angleGirth >= girth) { 154 | angleGirth = girth - lineLenth; 155 | endAngle = M_PI - angleGirth / radius; 156 | filish = YES; 157 | } 158 | }else { 159 | angleGirth = radius * (M_PI * 2 - angle); 160 | 161 | if (lineLenth + angleGirth >= girth) { 162 | angleGirth = girth - lineLenth; 163 | endAngle = M_PI + angleGirth / radius;; 164 | filish = YES; 165 | } 166 | } 167 | 168 | point.x += radius; 169 | [path addArcWithCenter:point radius:radius startAngle:angle endAngle:endAngle clockwise:clockwise]; 170 | point.x += radius; 171 | 172 | lineHeight = lineHeight_Max; 173 | lineLenth += angleGirth; 174 | } 175 | 176 | isLine = !isLine; 177 | 178 | } while (!filish); 179 | 180 | return path; 181 | } 182 | 183 | - (void)stopAnimation { 184 | [shapeLayer1 removeAllAnimations]; 185 | [shapeLayer2 removeAllAnimations]; 186 | 187 | shapeLayer1.hidden = YES; 188 | shapeLayer2.hidden = YES; 189 | } 190 | 191 | - (void)starAnimation { 192 | shapeLayer1.hidden = NO; 193 | shapeLayer2.hidden = NO; 194 | CGFloat offsetX = 4 * radius; 195 | shapeLayer1.path = [self sinPathWithProgress:0 offsetX:0].CGPath; 196 | shapeLayer2.path = [self sinPathWithProgress:0 offsetX:offsetX].CGPath; 197 | shapeLayer1.transform = CATransform3DTranslate(shapeLayer1.transform, -4*radius, 0, 0); 198 | shapeLayer2.transform = CATransform3DTranslate(shapeLayer2.transform, -4*radius, 0, 0); 199 | 200 | CABasicAnimation *animation1 = [CABasicAnimation animation]; 201 | animation1.keyPath = @"transform"; 202 | animation1.toValue = [NSValue valueWithCATransform3D:CATransform3DTranslate(shapeLayer1.transform, 4*radius, 0, 0)]; 203 | 204 | CABasicAnimation *animation4 = [CABasicAnimation animation]; 205 | animation4.keyPath = @"transform"; 206 | animation4.toValue = [NSValue valueWithCATransform3D:CATransform3DTranslate(shapeLayer2.transform, 4*radius, 0, 0)]; 207 | 208 | CABasicAnimation *animation2 = [CABasicAnimation animation]; 209 | animation2.keyPath = @"strokeStart"; 210 | animation2.fromValue = @(2 / 3.0); 211 | animation2.toValue = @(0); 212 | 213 | CABasicAnimation *animation3 = [CABasicAnimation animation]; 214 | animation3.keyPath = @"strokeEnd"; 215 | animation3.fromValue = @(1); 216 | animation3.toValue = @(1 / 3.0); 217 | 218 | CAAnimationGroup *group1 = [CAAnimationGroup animation]; 219 | group1.animations = @[animation1, animation2]; 220 | group1.duration = 0.7; 221 | group1.repeatCount = INT_MAX; 222 | 223 | CAAnimationGroup *group2 = [CAAnimationGroup animation]; 224 | group2.animations = @[animation4, animation3]; 225 | group2.duration = 0.7; 226 | group2.repeatCount = INT_MAX; 227 | 228 | [shapeLayer1 addAnimation:group1 forKey:nil]; 229 | [shapeLayer2 addAnimation:group2 forKey:nil]; 230 | } 231 | 232 | #pragma mark - Setter 233 | 234 | - (void)setLineWidth:(CGFloat)lineWidth { 235 | _lineWidth = lineWidth; 236 | shapeLayer1.lineWidth = lineWidth; 237 | shapeLayer2.lineWidth = lineWidth; 238 | 239 | radius = (CGRectGetWidth(self.frame) - 2 * lineWidth) / 6.0; 240 | } 241 | @end 242 | -------------------------------------------------------------------------------- /LoadingAnimation/UIColor+More.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIColor+More.h 3 | // JLnews 4 | // 5 | // Created by he15his on 13-12-6. 6 | // Copyright (c) 2013年 he15his. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIColor (More) 12 | 13 | @property (nonatomic, readonly) CGFloat red; 14 | @property (nonatomic, readonly) CGFloat green; 15 | @property (nonatomic, readonly) CGFloat blue; 16 | @property (nonatomic, readonly) CGFloat alpha; 17 | 18 | + (void)registerColor:(UIColor *)color forName:(NSString *)name; 19 | 20 | + (UIColor *)colorWithString:(NSString *)string; 21 | + (UIColor *)colorWithRGBValue:(uint32_t)rgb; 22 | + (UIColor *)colorWithRGBAValue:(uint32_t)rgba; 23 | - (UIColor *)initWithString:(NSString *)string; 24 | - (UIColor *)initWithRGBValue:(uint32_t)rgb; 25 | - (UIColor *)initWithRGBAValue:(uint32_t)rgba; 26 | 27 | - (uint32_t)RGBValue; 28 | - (uint32_t)RGBAValue; 29 | - (NSString *)stringValue; 30 | 31 | - (BOOL)isMonochromeOrRGB; 32 | - (BOOL)isEquivalent:(id)object; 33 | - (BOOL)isEquivalentToColor:(UIColor *)color; 34 | 35 | - (UIColor *)colorWithBrightness:(CGFloat)brightness; 36 | - (UIColor *)colorBlendedWithColor:(UIColor *)color factor:(CGFloat)factor; 37 | 38 | //+ (UIColor *)themeColorNamed:(NSString *)key; 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /LoadingAnimation/UIColor+More.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIColor+More.m 3 | // JLnews 4 | // 5 | // Created by he15his on 13-12-6. 6 | // Copyright (c) 2013年 he15his. All rights reserved. 7 | // 8 | 9 | #import "UIColor+More.h" 10 | 11 | @implementation UIColor (More) 12 | 13 | + (NSMutableDictionary *)standardColors 14 | { 15 | static NSMutableDictionary *colors = nil; 16 | static dispatch_once_t onceToken; 17 | dispatch_once(&onceToken, ^{ 18 | 19 | colors = [@{@"black": [self blackColor], // 0.0 white 20 | @"darkgray": [self darkGrayColor], // 0.333 white 21 | @"lightgray": [self lightGrayColor], // 0.667 white 22 | @"white": [self whiteColor], // 1.0 white 23 | @"gray": [self grayColor], // 0.5 white 24 | @"red": [self redColor], // 1.0, 0.0, 0.0 RGB 25 | @"green": [self greenColor], // 0.0, 1.0, 0.0 RGB 26 | @"blue": [self blueColor], // 0.0, 0.0, 1.0 RGB 27 | @"cyan": [self cyanColor], // 0.0, 1.0, 1.0 RGB 28 | @"yellow": [self yellowColor], // 1.0, 1.0, 0.0 RGB 29 | @"magenta": [self magentaColor], // 1.0, 0.0, 1.0 RGB 30 | @"orange": [self orangeColor], // 1.0, 0.5, 0.0 RGB 31 | @"purple": [self purpleColor], // 0.5, 0.0, 0.5 RGB 32 | @"brown": [self brownColor], // 0.6, 0.4, 0.2 RGB 33 | @"clear": [self clearColor]} mutableCopy]; 34 | }); 35 | 36 | return colors; 37 | } 38 | 39 | - (void)getRGBAComponents:(CGFloat[4])rgba 40 | { 41 | CGColorSpaceModel model = CGColorSpaceGetModel(CGColorGetColorSpace(self.CGColor)); 42 | const CGFloat *components = CGColorGetComponents(self.CGColor); 43 | switch (model) 44 | { 45 | case kCGColorSpaceModelMonochrome: 46 | { 47 | rgba[0] = components[0]; 48 | rgba[1] = components[0]; 49 | rgba[2] = components[0]; 50 | rgba[3] = components[1]; 51 | break; 52 | } 53 | case kCGColorSpaceModelRGB: 54 | { 55 | rgba[0] = components[0]; 56 | rgba[1] = components[1]; 57 | rgba[2] = components[2]; 58 | rgba[3] = components[3]; 59 | break; 60 | } 61 | default: 62 | { 63 | 64 | #ifdef DEBUG 65 | 66 | //unsupported format 67 | NSLog(@"Unsupported color model: %i", model); 68 | #endif 69 | rgba[0] = 0.0f; 70 | rgba[1] = 0.0f; 71 | rgba[2] = 0.0f; 72 | rgba[3] = 1.0f; 73 | break; 74 | } 75 | } 76 | } 77 | 78 | + (void)registerColor:(UIColor *)color forName:(NSString *)name 79 | { 80 | name = [name lowercaseString]; 81 | 82 | #ifdef DEBUG 83 | 84 | //don't allow re-registration 85 | NSAssert([self standardColors][name] == nil || [[self standardColors][name] isEquivalentToColor:color], 86 | @"Cannot re-register the color '%@' as this is already assigned", name); 87 | 88 | #endif 89 | 90 | [self standardColors][[name lowercaseString]] = color; 91 | } 92 | 93 | + (UIColor *)colorWithString:(NSString *)string 94 | { 95 | //convert to lowercase 96 | string = [string lowercaseString]; 97 | 98 | //try standard colors first 99 | UIColor *color = [self standardColors][string]; 100 | if (color) 101 | { 102 | return color; 103 | } 104 | 105 | //create new instance 106 | return [[self alloc] initWithString:string]; 107 | } 108 | 109 | + (UIColor *)colorWithRGBValue:(uint32_t)rgb 110 | { 111 | return [[self alloc] initWithRGBValue:rgb]; 112 | } 113 | 114 | + (UIColor *)colorWithRGBAValue:(uint32_t)rgba 115 | { 116 | return [[self alloc] initWithRGBAValue:rgba]; 117 | } 118 | 119 | - (UIColor *)initWithString:(NSString *)string 120 | { 121 | //convert to lowercase 122 | string = [string lowercaseString]; 123 | 124 | //try standard colors 125 | UIColor *color = [[self class] standardColors][string]; 126 | if (color) 127 | { 128 | return ((self = color)); 129 | } 130 | 131 | //try hex 132 | string = [string stringByReplacingOccurrencesOfString:@"#" withString:@""]; 133 | string = [string stringByReplacingOccurrencesOfString:@"0x" withString:@""]; 134 | switch ([string length]) 135 | { 136 | case 0: 137 | { 138 | string = @"00000000"; 139 | break; 140 | } 141 | case 3: 142 | { 143 | NSString *red = [string substringWithRange:NSMakeRange(0, 1)]; 144 | NSString *green = [string substringWithRange:NSMakeRange(1, 1)]; 145 | NSString *blue = [string substringWithRange:NSMakeRange(2, 1)]; 146 | string = [NSString stringWithFormat:@"%1$@%1$@%2$@%2$@%3$@%3$@ff", red, green, blue]; 147 | break; 148 | } 149 | case 6: 150 | { 151 | string = [string stringByAppendingString:@"ff"]; 152 | break; 153 | } 154 | case 8: 155 | { 156 | //do nothing 157 | break; 158 | } 159 | default: 160 | { 161 | 162 | #ifdef DEBUG 163 | 164 | //unsupported format 165 | NSLog(@"Unsupported color string format: %@", string); 166 | #endif 167 | return nil; 168 | } 169 | } 170 | uint32_t rgba; 171 | NSScanner *scanner = [NSScanner scannerWithString:string]; 172 | [scanner scanHexInt:&rgba]; 173 | return [self initWithRGBAValue:rgba]; 174 | } 175 | 176 | - (UIColor *)initWithRGBValue:(uint32_t)rgb 177 | { 178 | CGFloat red = ((rgb & 0xFF0000) >> 16) / 255.0f; 179 | CGFloat green = ((rgb & 0x00FF00) >> 8) / 255.0f; 180 | CGFloat blue = (rgb & 0x0000FF) / 255.0f; 181 | return [self initWithRed:red green:green blue:blue alpha:1.0f]; 182 | } 183 | 184 | - (UIColor *)initWithRGBAValue:(uint32_t)rgba 185 | { 186 | CGFloat red = ((rgba & 0xFF000000) >> 24) / 255.0f; 187 | CGFloat green = ((rgba & 0x00FF0000) >> 16) / 255.0f; 188 | CGFloat blue = ((rgba & 0x0000FF00) >> 8) / 255.0f; 189 | CGFloat alpha = (rgba & 0x000000FF) / 255.0f; 190 | return [self initWithRed:red green:green blue:blue alpha:alpha]; 191 | } 192 | 193 | - (uint32_t)RGBValue 194 | { 195 | CGFloat rgba[4]; 196 | [self getRGBAComponents:rgba]; 197 | uint8_t red = rgba[0]*255; 198 | uint8_t green = rgba[1]*255; 199 | uint8_t blue = rgba[2]*255; 200 | return (red << 16) + (green << 8) + blue; 201 | } 202 | 203 | - (uint32_t)RGBAValue 204 | { 205 | CGFloat rgba[4]; 206 | [self getRGBAComponents:rgba]; 207 | uint8_t red = rgba[0]*255; 208 | uint8_t green = rgba[1]*255; 209 | uint8_t blue = rgba[2]*255; 210 | uint8_t alpha = rgba[3]*255; 211 | return (red << 24) + (green << 16) + (blue << 8) + alpha; 212 | } 213 | 214 | - (NSString *)stringValue 215 | { 216 | //try standard colors 217 | NSUInteger index = [[[[self class] standardColors] allValues] indexOfObject:self]; 218 | if (index != NSNotFound) 219 | { 220 | return [[[self class] standardColors] allKeys][index]; 221 | } 222 | 223 | //convert to hex 224 | if (self.alpha < 1.0f) 225 | { 226 | //include alpha component 227 | return [NSString stringWithFormat:@"#%.8x", self.RGBAValue]; 228 | } 229 | else 230 | { 231 | //don't include alpha component 232 | return [NSString stringWithFormat:@"#%.6x", self.RGBValue]; 233 | } 234 | } 235 | 236 | - (CGFloat)red 237 | { 238 | CGFloat rgba[4]; 239 | [self getRGBAComponents:rgba]; 240 | return rgba[0]; 241 | } 242 | 243 | - (CGFloat)green 244 | { 245 | CGFloat rgba[4]; 246 | [self getRGBAComponents:rgba]; 247 | return rgba[1]; 248 | } 249 | 250 | - (CGFloat)blue 251 | { 252 | CGFloat rgba[4]; 253 | [self getRGBAComponents:rgba]; 254 | return rgba[2]; 255 | } 256 | 257 | - (CGFloat)alpha 258 | { 259 | return CGColorGetAlpha(self.CGColor); 260 | } 261 | 262 | - (BOOL)isMonochromeOrRGB 263 | { 264 | CGColorSpaceModel model = CGColorSpaceGetModel(CGColorGetColorSpace(self.CGColor)); 265 | return model == kCGColorSpaceModelMonochrome || model == kCGColorSpaceModelRGB; 266 | } 267 | 268 | - (BOOL)isEquivalent:(id)object 269 | { 270 | if ([object isKindOfClass:[self class]]) 271 | { 272 | return [self isEquivalentToColor:object]; 273 | } 274 | return NO; 275 | } 276 | 277 | - (BOOL)isEquivalentToColor:(UIColor *)color 278 | { 279 | if ([self isMonochromeOrRGB] && [color isMonochromeOrRGB]) 280 | { 281 | return self.RGBAValue == color.RGBAValue; 282 | } 283 | return [self isEqual:color]; 284 | } 285 | 286 | - (UIColor *)colorWithBrightness:(CGFloat)brightness 287 | { 288 | brightness = fminf(fmaxf(brightness, 0.0f), 1.0f); 289 | 290 | CGFloat rgba[4]; 291 | [self getRGBAComponents:rgba]; 292 | 293 | return [[self class] colorWithRed:rgba[0] * brightness 294 | green:rgba[1] * brightness 295 | blue:rgba[2] * brightness 296 | alpha:rgba[3]]; 297 | } 298 | 299 | - (UIColor *)colorBlendedWithColor:(UIColor *)color factor:(CGFloat)factor 300 | { 301 | factor = fminf(fmaxf(factor, 0.0f), 1.0f); 302 | 303 | CGFloat fromRGBA[4], toRGBA[4]; 304 | [self getRGBAComponents:fromRGBA]; 305 | [color getRGBAComponents:toRGBA]; 306 | 307 | return [[self class] colorWithRed:fromRGBA[0] + (toRGBA[0] - fromRGBA[0]) * factor 308 | green:fromRGBA[1] + (toRGBA[1] - fromRGBA[1]) * factor 309 | blue:fromRGBA[2] + (toRGBA[2] - fromRGBA[2]) * factor 310 | alpha:fromRGBA[3] + (toRGBA[3] - fromRGBA[3]) * factor]; 311 | } 312 | 313 | //+ (UIColor *)themeColorNamed:(NSString *)key 314 | //{ 315 | // return [UIColor colorWithString:[JLThemeManagerSingeton.styles objectForKey:key]]; 316 | //} 317 | 318 | @end 319 | -------------------------------------------------------------------------------- /LoadingAnimation/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // LoadingAnimation 4 | // 5 | // Created by he15his on 15/6/4. 6 | // Copyright (c) 2015年 he15his. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /LoadingAnimation/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // LoadingAnimation 4 | // 5 | // Created by he15his on 15/6/4. 6 | // Copyright (c) 2015年 he15his. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "SinLoadingView.h" 11 | #import "UIColor+More.h" 12 | #import "SnakeLoadingView.h" 13 | 14 | @interface ViewController () 15 | 16 | @end 17 | 18 | @implementation ViewController 19 | 20 | - (void)viewDidLoad { 21 | [super viewDidLoad]; 22 | // Do any additional setup after loading the view, typically from a nib. 23 | 24 | SinLoadingView *sinView = [[SinLoadingView alloc] initWithFrame:CGRectMake(0, 0, 200, 100)]; 25 | sinView.backgroundColor = [UIColor colorWithString:@"#fcce2f"]; 26 | sinView.center = CGPointMake(self.view.center.x, self.view.center.y-100); 27 | [self.view addSubview:sinView]; 28 | 29 | SnakeLoadingView *snakeView = [[SnakeLoadingView alloc] initWithFrame:CGRectMake(0, 0, 200, 130)]; 30 | snakeView.center = CGPointMake(self.view.center.x, self.view.center.y+100);; 31 | snakeView.lineWidth = 33; 32 | snakeView.layer.shadowOpacity = 0.5; 33 | snakeView.layer.shadowOffset = CGSizeMake(0, 10); 34 | snakeView.layer.shadowColor = [UIColor colorWithString:@"#d1f7eb"].CGColor; 35 | [self.view addSubview:snakeView]; 36 | [snakeView starAnimation]; 37 | 38 | // [sinView performSelector:@selector(stopAnimation) withObject:nil afterDelay:10]; 39 | } 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /LoadingAnimation/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // LoadingAnimation 4 | // 5 | // Created by he15his on 15/6/4. 6 | // Copyright (c) 2015年 he15his. 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 | -------------------------------------------------------------------------------- /LoadingAnimationTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | he15his.$(PRODUCT_NAME:rfc1034identifier) 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 | -------------------------------------------------------------------------------- /LoadingAnimationTests/LoadingAnimationTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // LoadingAnimationTests.m 3 | // LoadingAnimationTests 4 | // 5 | // Created by he15his on 15/6/4. 6 | // Copyright (c) 2015年 he15his. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface LoadingAnimationTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation LoadingAnimationTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LoadingAnimation 2 | 两个比较炫的加载动画 3 | 4 | 效果如下 5 | 6 | ![图片1](https://github.com/he15his/LoadingAnimation/blob/master/UI.Animation.uisheji.com199119910.gif) 7 | 8 | ![图片2](https://github.com/he15his/LoadingAnimation/blob/master/ui.animatton.uisheji.com_.gif-0392.gif) -------------------------------------------------------------------------------- /UI.Animation.uisheji.com199119910.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/he15his/LoadingAnimation/71ca1133c411c9db1ef01edd4c6ed189b27c08e1/UI.Animation.uisheji.com199119910.gif -------------------------------------------------------------------------------- /ui.animatton.uisheji.com_.gif-0392.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/he15his/LoadingAnimation/71ca1133c411c9db1ef01edd4c6ed189b27c08e1/ui.animatton.uisheji.com_.gif-0392.gif --------------------------------------------------------------------------------