├── .gitignore ├── .travis.yml ├── Example ├── JDAnimationKit.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── JDAnimationKit-Example.xcscheme ├── JDAnimationKit.xcworkspace │ └── contents.xcworkspacedata ├── JDAnimationKit │ ├── AppDelegate.swift │ ├── Base.lproj │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Info.plist │ └── ViewController.swift ├── Podfile └── Tests │ ├── Info.plist │ └── Tests.swift ├── JDAnimationKit.podspec ├── LICENSE ├── Pod ├── Assets │ └── .gitkeep └── Classes │ ├── .gitkeep │ └── JDAnimationKit.swift ├── README.md └── _Pods.xcodeproj /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | .xcodeproj/* 21 | !*.xcodeproj/*.pbxproj 22 | !*.xcodeproj/xcshareddata 23 | 24 | .xcworkspace/* 25 | !*.xcworkspace/*.xcworkspacedata 26 | 27 | pkg/* 28 | 29 | Pods 30 | Podfile.lock -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # references: 2 | # * http://www.objc.io/issue-6/travis-ci.html 3 | # * https://github.com/supermarin/xcpretty#usage 4 | 5 | language: objective-c 6 | # cache: cocoapods 7 | # podfile: Example/Podfile 8 | # before_install: 9 | # - gem install cocoapods # Since Travis is not always on latest version 10 | # - pod install --project-directory=Example 11 | script: 12 | - set -o pipefail && xcodebuild test -workspace Example/JDAnimationKit.xcworkspace -scheme JDAnimationKit-Example -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO | xcpretty 13 | - pod lib lint 14 | -------------------------------------------------------------------------------- /Example/JDAnimationKit.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD51AFB9204008FA782 /* AppDelegate.swift */; }; 11 | 607FACD81AFB9204008FA782 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD71AFB9204008FA782 /* ViewController.swift */; }; 12 | 607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 607FACD91AFB9204008FA782 /* Main.storyboard */; }; 13 | 607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; }; 14 | 607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; }; 15 | 607FACEC1AFB9204008FA782 /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACEB1AFB9204008FA782 /* Tests.swift */; }; 16 | 8AD0A584FBC487B96481DB9A /* Pods_JDAnimationKit_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3A981A5ADE2BD9F9DB2D7A13 /* Pods_JDAnimationKit_Example.framework */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXContainerItemProxy section */ 20 | 607FACE61AFB9204008FA782 /* PBXContainerItemProxy */ = { 21 | isa = PBXContainerItemProxy; 22 | containerPortal = 607FACC81AFB9204008FA782 /* Project object */; 23 | proxyType = 1; 24 | remoteGlobalIDString = 607FACCF1AFB9204008FA782; 25 | remoteInfo = JDAnimationKit; 26 | }; 27 | /* End PBXContainerItemProxy section */ 28 | 29 | /* Begin PBXFileReference section */ 30 | 33A145FFD6CF0954669559BA /* JDAnimationKit.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = JDAnimationKit.podspec; path = ../JDAnimationKit.podspec; sourceTree = ""; }; 31 | 3A981A5ADE2BD9F9DB2D7A13 /* Pods_JDAnimationKit_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_JDAnimationKit_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 32 | 3C662A544AF88C499E2238E5 /* Pods-JDAnimationKit_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-JDAnimationKit_Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-JDAnimationKit_Example/Pods-JDAnimationKit_Example.release.xcconfig"; sourceTree = ""; }; 33 | 607FACD01AFB9204008FA782 /* JDAnimationKit_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = JDAnimationKit_Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; 34 | 607FACD41AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 35 | 607FACD51AFB9204008FA782 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 36 | 607FACD71AFB9204008FA782 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 37 | 607FACDA1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 38 | 607FACDC1AFB9204008FA782 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 39 | 607FACDF1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 40 | 607FACE51AFB9204008FA782 /* JDAnimationKit_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = JDAnimationKit_Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 41 | 607FACEA1AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 42 | 607FACEB1AFB9204008FA782 /* Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tests.swift; sourceTree = ""; }; 43 | 62ACB2A32C4B81A5D497E0B6 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = ""; }; 44 | 69C045ADB5EBEF6217EADFA2 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; }; 45 | A7CEF63097A766D922929D04 /* Pods-JDAnimationKit_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-JDAnimationKit_Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-JDAnimationKit_Example/Pods-JDAnimationKit_Example.debug.xcconfig"; sourceTree = ""; }; 46 | /* End PBXFileReference section */ 47 | 48 | /* Begin PBXFrameworksBuildPhase section */ 49 | 607FACCD1AFB9204008FA782 /* Frameworks */ = { 50 | isa = PBXFrameworksBuildPhase; 51 | buildActionMask = 2147483647; 52 | files = ( 53 | 8AD0A584FBC487B96481DB9A /* Pods_JDAnimationKit_Example.framework in Frameworks */, 54 | ); 55 | runOnlyForDeploymentPostprocessing = 0; 56 | }; 57 | 607FACE21AFB9204008FA782 /* Frameworks */ = { 58 | isa = PBXFrameworksBuildPhase; 59 | buildActionMask = 2147483647; 60 | files = ( 61 | ); 62 | runOnlyForDeploymentPostprocessing = 0; 63 | }; 64 | /* End PBXFrameworksBuildPhase section */ 65 | 66 | /* Begin PBXGroup section */ 67 | 607FACC71AFB9204008FA782 = { 68 | isa = PBXGroup; 69 | children = ( 70 | 607FACF51AFB993E008FA782 /* Podspec Metadata */, 71 | 607FACD21AFB9204008FA782 /* Example for JDAnimationKit */, 72 | 607FACE81AFB9204008FA782 /* Tests */, 73 | 607FACD11AFB9204008FA782 /* Products */, 74 | E04D7D65EB68E7B0C699AC75 /* Pods */, 75 | C2C9988AD168949800F38BDA /* Frameworks */, 76 | ); 77 | sourceTree = ""; 78 | }; 79 | 607FACD11AFB9204008FA782 /* Products */ = { 80 | isa = PBXGroup; 81 | children = ( 82 | 607FACD01AFB9204008FA782 /* JDAnimationKit_Example.app */, 83 | 607FACE51AFB9204008FA782 /* JDAnimationKit_Tests.xctest */, 84 | ); 85 | name = Products; 86 | sourceTree = ""; 87 | }; 88 | 607FACD21AFB9204008FA782 /* Example for JDAnimationKit */ = { 89 | isa = PBXGroup; 90 | children = ( 91 | 607FACD51AFB9204008FA782 /* AppDelegate.swift */, 92 | 607FACD71AFB9204008FA782 /* ViewController.swift */, 93 | 607FACD91AFB9204008FA782 /* Main.storyboard */, 94 | 607FACDC1AFB9204008FA782 /* Images.xcassets */, 95 | 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */, 96 | 607FACD31AFB9204008FA782 /* Supporting Files */, 97 | ); 98 | name = "Example for JDAnimationKit"; 99 | path = JDAnimationKit; 100 | sourceTree = ""; 101 | }; 102 | 607FACD31AFB9204008FA782 /* Supporting Files */ = { 103 | isa = PBXGroup; 104 | children = ( 105 | 607FACD41AFB9204008FA782 /* Info.plist */, 106 | ); 107 | name = "Supporting Files"; 108 | sourceTree = ""; 109 | }; 110 | 607FACE81AFB9204008FA782 /* Tests */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | 607FACEB1AFB9204008FA782 /* Tests.swift */, 114 | 607FACE91AFB9204008FA782 /* Supporting Files */, 115 | ); 116 | path = Tests; 117 | sourceTree = ""; 118 | }; 119 | 607FACE91AFB9204008FA782 /* Supporting Files */ = { 120 | isa = PBXGroup; 121 | children = ( 122 | 607FACEA1AFB9204008FA782 /* Info.plist */, 123 | ); 124 | name = "Supporting Files"; 125 | sourceTree = ""; 126 | }; 127 | 607FACF51AFB993E008FA782 /* Podspec Metadata */ = { 128 | isa = PBXGroup; 129 | children = ( 130 | 33A145FFD6CF0954669559BA /* JDAnimationKit.podspec */, 131 | 69C045ADB5EBEF6217EADFA2 /* README.md */, 132 | 62ACB2A32C4B81A5D497E0B6 /* LICENSE */, 133 | ); 134 | name = "Podspec Metadata"; 135 | sourceTree = ""; 136 | }; 137 | C2C9988AD168949800F38BDA /* Frameworks */ = { 138 | isa = PBXGroup; 139 | children = ( 140 | 3A981A5ADE2BD9F9DB2D7A13 /* Pods_JDAnimationKit_Example.framework */, 141 | ); 142 | name = Frameworks; 143 | sourceTree = ""; 144 | }; 145 | E04D7D65EB68E7B0C699AC75 /* Pods */ = { 146 | isa = PBXGroup; 147 | children = ( 148 | A7CEF63097A766D922929D04 /* Pods-JDAnimationKit_Example.debug.xcconfig */, 149 | 3C662A544AF88C499E2238E5 /* Pods-JDAnimationKit_Example.release.xcconfig */, 150 | ); 151 | name = Pods; 152 | sourceTree = ""; 153 | }; 154 | /* End PBXGroup section */ 155 | 156 | /* Begin PBXNativeTarget section */ 157 | 607FACCF1AFB9204008FA782 /* JDAnimationKit_Example */ = { 158 | isa = PBXNativeTarget; 159 | buildConfigurationList = 607FACEF1AFB9204008FA782 /* Build configuration list for PBXNativeTarget "JDAnimationKit_Example" */; 160 | buildPhases = ( 161 | 9AEF00E6992DDDE705363D54 /* [CP] Check Pods Manifest.lock */, 162 | 607FACCC1AFB9204008FA782 /* Sources */, 163 | 607FACCD1AFB9204008FA782 /* Frameworks */, 164 | 607FACCE1AFB9204008FA782 /* Resources */, 165 | 52C1E04C2A2149429F554167 /* [CP] Embed Pods Frameworks */, 166 | F53BF809A5C2E2FF97469218 /* [CP] Copy Pods Resources */, 167 | ); 168 | buildRules = ( 169 | ); 170 | dependencies = ( 171 | ); 172 | name = JDAnimationKit_Example; 173 | productName = JDAnimationKit; 174 | productReference = 607FACD01AFB9204008FA782 /* JDAnimationKit_Example.app */; 175 | productType = "com.apple.product-type.application"; 176 | }; 177 | 607FACE41AFB9204008FA782 /* JDAnimationKit_Tests */ = { 178 | isa = PBXNativeTarget; 179 | buildConfigurationList = 607FACF21AFB9204008FA782 /* Build configuration list for PBXNativeTarget "JDAnimationKit_Tests" */; 180 | buildPhases = ( 181 | 607FACE11AFB9204008FA782 /* Sources */, 182 | 607FACE21AFB9204008FA782 /* Frameworks */, 183 | 607FACE31AFB9204008FA782 /* Resources */, 184 | ); 185 | buildRules = ( 186 | ); 187 | dependencies = ( 188 | 607FACE71AFB9204008FA782 /* PBXTargetDependency */, 189 | ); 190 | name = JDAnimationKit_Tests; 191 | productName = Tests; 192 | productReference = 607FACE51AFB9204008FA782 /* JDAnimationKit_Tests.xctest */; 193 | productType = "com.apple.product-type.bundle.unit-test"; 194 | }; 195 | /* End PBXNativeTarget section */ 196 | 197 | /* Begin PBXProject section */ 198 | 607FACC81AFB9204008FA782 /* Project object */ = { 199 | isa = PBXProject; 200 | attributes = { 201 | LastSwiftUpdateCheck = 0720; 202 | LastUpgradeCheck = 0810; 203 | ORGANIZATIONNAME = CocoaPods; 204 | TargetAttributes = { 205 | 607FACCF1AFB9204008FA782 = { 206 | CreatedOnToolsVersion = 6.3.1; 207 | LastSwiftMigration = 0810; 208 | }; 209 | 607FACE41AFB9204008FA782 = { 210 | CreatedOnToolsVersion = 6.3.1; 211 | LastSwiftMigration = 0810; 212 | TestTargetID = 607FACCF1AFB9204008FA782; 213 | }; 214 | }; 215 | }; 216 | buildConfigurationList = 607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "JDAnimationKit" */; 217 | compatibilityVersion = "Xcode 3.2"; 218 | developmentRegion = English; 219 | hasScannedForEncodings = 0; 220 | knownRegions = ( 221 | en, 222 | Base, 223 | ); 224 | mainGroup = 607FACC71AFB9204008FA782; 225 | productRefGroup = 607FACD11AFB9204008FA782 /* Products */; 226 | projectDirPath = ""; 227 | projectRoot = ""; 228 | targets = ( 229 | 607FACCF1AFB9204008FA782 /* JDAnimationKit_Example */, 230 | 607FACE41AFB9204008FA782 /* JDAnimationKit_Tests */, 231 | ); 232 | }; 233 | /* End PBXProject section */ 234 | 235 | /* Begin PBXResourcesBuildPhase section */ 236 | 607FACCE1AFB9204008FA782 /* Resources */ = { 237 | isa = PBXResourcesBuildPhase; 238 | buildActionMask = 2147483647; 239 | files = ( 240 | 607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */, 241 | 607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */, 242 | 607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */, 243 | ); 244 | runOnlyForDeploymentPostprocessing = 0; 245 | }; 246 | 607FACE31AFB9204008FA782 /* Resources */ = { 247 | isa = PBXResourcesBuildPhase; 248 | buildActionMask = 2147483647; 249 | files = ( 250 | ); 251 | runOnlyForDeploymentPostprocessing = 0; 252 | }; 253 | /* End PBXResourcesBuildPhase section */ 254 | 255 | /* Begin PBXShellScriptBuildPhase section */ 256 | 52C1E04C2A2149429F554167 /* [CP] Embed Pods Frameworks */ = { 257 | isa = PBXShellScriptBuildPhase; 258 | buildActionMask = 2147483647; 259 | files = ( 260 | ); 261 | inputPaths = ( 262 | ); 263 | name = "[CP] Embed Pods Frameworks"; 264 | outputPaths = ( 265 | ); 266 | runOnlyForDeploymentPostprocessing = 0; 267 | shellPath = /bin/sh; 268 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-JDAnimationKit_Example/Pods-JDAnimationKit_Example-frameworks.sh\"\n"; 269 | showEnvVarsInLog = 0; 270 | }; 271 | 9AEF00E6992DDDE705363D54 /* [CP] Check Pods Manifest.lock */ = { 272 | isa = PBXShellScriptBuildPhase; 273 | buildActionMask = 2147483647; 274 | files = ( 275 | ); 276 | inputPaths = ( 277 | ); 278 | name = "[CP] Check Pods Manifest.lock"; 279 | outputPaths = ( 280 | ); 281 | runOnlyForDeploymentPostprocessing = 0; 282 | shellPath = /bin/sh; 283 | shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; 284 | showEnvVarsInLog = 0; 285 | }; 286 | F53BF809A5C2E2FF97469218 /* [CP] Copy Pods Resources */ = { 287 | isa = PBXShellScriptBuildPhase; 288 | buildActionMask = 2147483647; 289 | files = ( 290 | ); 291 | inputPaths = ( 292 | ); 293 | name = "[CP] Copy Pods Resources"; 294 | outputPaths = ( 295 | ); 296 | runOnlyForDeploymentPostprocessing = 0; 297 | shellPath = /bin/sh; 298 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-JDAnimationKit_Example/Pods-JDAnimationKit_Example-resources.sh\"\n"; 299 | showEnvVarsInLog = 0; 300 | }; 301 | /* End PBXShellScriptBuildPhase section */ 302 | 303 | /* Begin PBXSourcesBuildPhase section */ 304 | 607FACCC1AFB9204008FA782 /* Sources */ = { 305 | isa = PBXSourcesBuildPhase; 306 | buildActionMask = 2147483647; 307 | files = ( 308 | 607FACD81AFB9204008FA782 /* ViewController.swift in Sources */, 309 | 607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */, 310 | ); 311 | runOnlyForDeploymentPostprocessing = 0; 312 | }; 313 | 607FACE11AFB9204008FA782 /* Sources */ = { 314 | isa = PBXSourcesBuildPhase; 315 | buildActionMask = 2147483647; 316 | files = ( 317 | 607FACEC1AFB9204008FA782 /* Tests.swift in Sources */, 318 | ); 319 | runOnlyForDeploymentPostprocessing = 0; 320 | }; 321 | /* End PBXSourcesBuildPhase section */ 322 | 323 | /* Begin PBXTargetDependency section */ 324 | 607FACE71AFB9204008FA782 /* PBXTargetDependency */ = { 325 | isa = PBXTargetDependency; 326 | target = 607FACCF1AFB9204008FA782 /* JDAnimationKit_Example */; 327 | targetProxy = 607FACE61AFB9204008FA782 /* PBXContainerItemProxy */; 328 | }; 329 | /* End PBXTargetDependency section */ 330 | 331 | /* Begin PBXVariantGroup section */ 332 | 607FACD91AFB9204008FA782 /* Main.storyboard */ = { 333 | isa = PBXVariantGroup; 334 | children = ( 335 | 607FACDA1AFB9204008FA782 /* Base */, 336 | ); 337 | name = Main.storyboard; 338 | sourceTree = ""; 339 | }; 340 | 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */ = { 341 | isa = PBXVariantGroup; 342 | children = ( 343 | 607FACDF1AFB9204008FA782 /* Base */, 344 | ); 345 | name = LaunchScreen.xib; 346 | sourceTree = ""; 347 | }; 348 | /* End PBXVariantGroup section */ 349 | 350 | /* Begin XCBuildConfiguration section */ 351 | 607FACED1AFB9204008FA782 /* Debug */ = { 352 | isa = XCBuildConfiguration; 353 | buildSettings = { 354 | ALWAYS_SEARCH_USER_PATHS = NO; 355 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 356 | CLANG_CXX_LIBRARY = "libc++"; 357 | CLANG_ENABLE_MODULES = YES; 358 | CLANG_ENABLE_OBJC_ARC = YES; 359 | CLANG_WARN_BOOL_CONVERSION = YES; 360 | CLANG_WARN_CONSTANT_CONVERSION = YES; 361 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 362 | CLANG_WARN_EMPTY_BODY = YES; 363 | CLANG_WARN_ENUM_CONVERSION = YES; 364 | CLANG_WARN_INFINITE_RECURSION = YES; 365 | CLANG_WARN_INT_CONVERSION = YES; 366 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 367 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 368 | CLANG_WARN_UNREACHABLE_CODE = YES; 369 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 370 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 371 | COPY_PHASE_STRIP = NO; 372 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 373 | ENABLE_STRICT_OBJC_MSGSEND = YES; 374 | ENABLE_TESTABILITY = YES; 375 | GCC_C_LANGUAGE_STANDARD = gnu99; 376 | GCC_DYNAMIC_NO_PIC = NO; 377 | GCC_NO_COMMON_BLOCKS = YES; 378 | GCC_OPTIMIZATION_LEVEL = 0; 379 | GCC_PREPROCESSOR_DEFINITIONS = ( 380 | "DEBUG=1", 381 | "$(inherited)", 382 | ); 383 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 384 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 385 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 386 | GCC_WARN_UNDECLARED_SELECTOR = YES; 387 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 388 | GCC_WARN_UNUSED_FUNCTION = YES; 389 | GCC_WARN_UNUSED_VARIABLE = YES; 390 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 391 | MTL_ENABLE_DEBUG_INFO = YES; 392 | ONLY_ACTIVE_ARCH = YES; 393 | SDKROOT = iphoneos; 394 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 395 | }; 396 | name = Debug; 397 | }; 398 | 607FACEE1AFB9204008FA782 /* Release */ = { 399 | isa = XCBuildConfiguration; 400 | buildSettings = { 401 | ALWAYS_SEARCH_USER_PATHS = NO; 402 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 403 | CLANG_CXX_LIBRARY = "libc++"; 404 | CLANG_ENABLE_MODULES = YES; 405 | CLANG_ENABLE_OBJC_ARC = YES; 406 | CLANG_WARN_BOOL_CONVERSION = YES; 407 | CLANG_WARN_CONSTANT_CONVERSION = YES; 408 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 409 | CLANG_WARN_EMPTY_BODY = YES; 410 | CLANG_WARN_ENUM_CONVERSION = YES; 411 | CLANG_WARN_INFINITE_RECURSION = YES; 412 | CLANG_WARN_INT_CONVERSION = YES; 413 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 414 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 415 | CLANG_WARN_UNREACHABLE_CODE = YES; 416 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 417 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 418 | COPY_PHASE_STRIP = NO; 419 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 420 | ENABLE_NS_ASSERTIONS = NO; 421 | ENABLE_STRICT_OBJC_MSGSEND = YES; 422 | GCC_C_LANGUAGE_STANDARD = gnu99; 423 | GCC_NO_COMMON_BLOCKS = YES; 424 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 425 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 426 | GCC_WARN_UNDECLARED_SELECTOR = YES; 427 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 428 | GCC_WARN_UNUSED_FUNCTION = YES; 429 | GCC_WARN_UNUSED_VARIABLE = YES; 430 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 431 | MTL_ENABLE_DEBUG_INFO = NO; 432 | SDKROOT = iphoneos; 433 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 434 | VALIDATE_PRODUCT = YES; 435 | }; 436 | name = Release; 437 | }; 438 | 607FACF01AFB9204008FA782 /* Debug */ = { 439 | isa = XCBuildConfiguration; 440 | baseConfigurationReference = A7CEF63097A766D922929D04 /* Pods-JDAnimationKit_Example.debug.xcconfig */; 441 | buildSettings = { 442 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 443 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 444 | CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO; 445 | INFOPLIST_FILE = JDAnimationKit/Info.plist; 446 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 447 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 448 | MODULE_NAME = ExampleApp; 449 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; 450 | PRODUCT_NAME = "$(TARGET_NAME)"; 451 | SWIFT_VERSION = 3.0; 452 | }; 453 | name = Debug; 454 | }; 455 | 607FACF11AFB9204008FA782 /* Release */ = { 456 | isa = XCBuildConfiguration; 457 | baseConfigurationReference = 3C662A544AF88C499E2238E5 /* Pods-JDAnimationKit_Example.release.xcconfig */; 458 | buildSettings = { 459 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 460 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 461 | CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO; 462 | INFOPLIST_FILE = JDAnimationKit/Info.plist; 463 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 464 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 465 | MODULE_NAME = ExampleApp; 466 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; 467 | PRODUCT_NAME = "$(TARGET_NAME)"; 468 | SWIFT_VERSION = 3.0; 469 | }; 470 | name = Release; 471 | }; 472 | 607FACF31AFB9204008FA782 /* Debug */ = { 473 | isa = XCBuildConfiguration; 474 | buildSettings = { 475 | BUNDLE_LOADER = "$(TEST_HOST)"; 476 | FRAMEWORK_SEARCH_PATHS = ( 477 | "$(SDKROOT)/Developer/Library/Frameworks", 478 | "$(inherited)", 479 | ); 480 | GCC_PREPROCESSOR_DEFINITIONS = ( 481 | "DEBUG=1", 482 | "$(inherited)", 483 | ); 484 | INFOPLIST_FILE = Tests/Info.plist; 485 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 486 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)"; 487 | PRODUCT_NAME = "$(TARGET_NAME)"; 488 | SWIFT_VERSION = 3.0; 489 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/JDAnimationKit_Example.app/JDAnimationKit_Example"; 490 | }; 491 | name = Debug; 492 | }; 493 | 607FACF41AFB9204008FA782 /* Release */ = { 494 | isa = XCBuildConfiguration; 495 | buildSettings = { 496 | BUNDLE_LOADER = "$(TEST_HOST)"; 497 | FRAMEWORK_SEARCH_PATHS = ( 498 | "$(SDKROOT)/Developer/Library/Frameworks", 499 | "$(inherited)", 500 | ); 501 | INFOPLIST_FILE = Tests/Info.plist; 502 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 503 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)"; 504 | PRODUCT_NAME = "$(TARGET_NAME)"; 505 | SWIFT_VERSION = 3.0; 506 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/JDAnimationKit_Example.app/JDAnimationKit_Example"; 507 | }; 508 | name = Release; 509 | }; 510 | /* End XCBuildConfiguration section */ 511 | 512 | /* Begin XCConfigurationList section */ 513 | 607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "JDAnimationKit" */ = { 514 | isa = XCConfigurationList; 515 | buildConfigurations = ( 516 | 607FACED1AFB9204008FA782 /* Debug */, 517 | 607FACEE1AFB9204008FA782 /* Release */, 518 | ); 519 | defaultConfigurationIsVisible = 0; 520 | defaultConfigurationName = Release; 521 | }; 522 | 607FACEF1AFB9204008FA782 /* Build configuration list for PBXNativeTarget "JDAnimationKit_Example" */ = { 523 | isa = XCConfigurationList; 524 | buildConfigurations = ( 525 | 607FACF01AFB9204008FA782 /* Debug */, 526 | 607FACF11AFB9204008FA782 /* Release */, 527 | ); 528 | defaultConfigurationIsVisible = 0; 529 | defaultConfigurationName = Release; 530 | }; 531 | 607FACF21AFB9204008FA782 /* Build configuration list for PBXNativeTarget "JDAnimationKit_Tests" */ = { 532 | isa = XCConfigurationList; 533 | buildConfigurations = ( 534 | 607FACF31AFB9204008FA782 /* Debug */, 535 | 607FACF41AFB9204008FA782 /* Release */, 536 | ); 537 | defaultConfigurationIsVisible = 0; 538 | defaultConfigurationName = Release; 539 | }; 540 | /* End XCConfigurationList section */ 541 | }; 542 | rootObject = 607FACC81AFB9204008FA782 /* Project object */; 543 | } 544 | -------------------------------------------------------------------------------- /Example/JDAnimationKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/JDAnimationKit.xcodeproj/xcshareddata/xcschemes/JDAnimationKit-Example.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 | 67 | 68 | 78 | 80 | 86 | 87 | 88 | 89 | 90 | 91 | 97 | 99 | 105 | 106 | 107 | 108 | 110 | 111 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /Example/JDAnimationKit.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Example/JDAnimationKit/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // JDAnimationKit 4 | // 5 | // Created by Juanpe on 02/22/2016. 6 | // Copyright (c) 2016 Juanpe. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // 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. 24 | // 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. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // 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. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // 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. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // 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. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /Example/JDAnimationKit/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 | -------------------------------------------------------------------------------- /Example/JDAnimationKit/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 | -------------------------------------------------------------------------------- /Example/JDAnimationKit/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 | } 39 | -------------------------------------------------------------------------------- /Example/JDAnimationKit/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 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /Example/JDAnimationKit/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // JDAnimationKit 4 | // 5 | // Created by Juanpe on 02/22/2016. 6 | // Copyright (c) 2016 Juanpe. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import JDAnimationKit 11 | 12 | class ViewController: UIViewController { 13 | 14 | @IBOutlet weak var squareView: UIView! 15 | 16 | override func viewDidLoad() { 17 | super.viewDidLoad() 18 | // Do any additional setup after loading the view, typically from a nib. 19 | } 20 | 21 | override func didReceiveMemoryWarning() { 22 | super.didReceiveMemoryWarning() 23 | // Dispose of any resources that can be recreated. 24 | } 25 | 26 | override func touchesBegan(_ touches: Set, with event: UIEvent?) { 27 | 28 | var frame = self.squareView.frame 29 | frame.size.width = frame.height 30 | 31 | self.squareView.changeAnchorPoint(0, y: 0.5) 32 | .changeBounds(frame, spring: true) 33 | .changeBgColor(UIColor.green) 34 | .changeAnchorPoint(0, y: 0, delay: 0.6) 35 | .rotateTo(60, spring: true, springConfig: JDSpringConfig(bounciness: 20, speed: 10), delay:0.7) 36 | .didStopAnimation { (node, key, finished, error) -> Void in 37 | 38 | if finished == true{ 39 | self.squareView.moveYTo(1000, duration: 0.8, timing: .easeIn).opacityTo(0, duration: 1) 40 | } 41 | } 42 | } 43 | } 44 | 45 | -------------------------------------------------------------------------------- /Example/Podfile: -------------------------------------------------------------------------------- 1 | source 'https://github.com/CocoaPods/Specs.git' 2 | use_frameworks! 3 | 4 | target 'JDAnimationKit_Example' do 5 | pod "JDAnimationKit", :path => "../" 6 | end 7 | 8 | post_install do |installer| 9 | `find Pods -regex 'Pods/pop.*\\.h' -print0 | xargs -0 sed -i '' 's/\\(<\\)pop\\/\\(.*\\)\\(>\\)/\\"\\2\\"/'` 10 | end -------------------------------------------------------------------------------- /Example/Tests/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 | -------------------------------------------------------------------------------- /Example/Tests/Tests.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import XCTest 3 | 4 | class Tests: XCTestCase { 5 | 6 | override func setUp() { 7 | super.setUp() 8 | // Put setup code here. This method is called before the invocation of each test method in the class. 9 | } 10 | 11 | override func tearDown() { 12 | // Put teardown code here. This method is called after the invocation of each test method in the class. 13 | super.tearDown() 14 | } 15 | 16 | func testExample() { 17 | // This is an example of a functional test case. 18 | XCTAssert(true, "Pass") 19 | } 20 | 21 | func testPerformanceExample() { 22 | // This is an example of a performance test case. 23 | self.measure() { 24 | // Put the code you want to measure the time of here. 25 | } 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /JDAnimationKit.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "JDAnimationKit" 3 | s.version = "1.1" 4 | s.summary = "You can animate your UI withe less lines of code" 5 | s.description = 'JDAnimationKit is designed to be extremely easy to use. You can animate your UI withe less lines of code' 6 | s.homepage = 'https://github.com/JellyDevelopment/JDAnimationKit' 7 | s.license = 'MIT' 8 | s.author = { "Juanpe" => "juanpecm@gmail.com" } 9 | s.source = { :git => "https://github.com/JellyDevelopment/JDAnimationKit.git", :tag => s.version.to_s } 10 | s.social_media_url = 'https://twitter.com/juanpecmios' 11 | 12 | s.platform = :ios, '8.0' 13 | s.requires_arc = true 14 | 15 | s.source_files = 'Pod/Classes/**/*' 16 | 17 | s.frameworks = 'UIKit' 18 | s.dependency 'pop', '~> 1.0' 19 | end 20 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Juanpe 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /Pod/Assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JellyDevelopment/JDAnimationKit/cb28ae8c28923ff2574bb17b313242ca1e3b2086/Pod/Assets/.gitkeep -------------------------------------------------------------------------------- /Pod/Classes/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JellyDevelopment/JDAnimationKit/cb28ae8c28923ff2574bb17b313242ca1e3b2086/Pod/Classes/.gitkeep -------------------------------------------------------------------------------- /Pod/Classes/JDAnimationKit.swift: -------------------------------------------------------------------------------- 1 | // 2 | // JDAnimationKit.swift 3 | // TestJDAnimationKit 4 | // 5 | // Created by Juan Pedro Catalán on 20/02/16. 6 | // Copyright © 2016 Juanpe Catalán. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import ObjectiveC 11 | import UIKit 12 | import pop 13 | 14 | public enum JDTimingFunction { 15 | case linear 16 | case easeIn 17 | case easeOut 18 | case easeInOut 19 | case none 20 | } 21 | 22 | struct JDAssociatedKeys { 23 | static var didStartBlockKey = "JDdidStartBlock" 24 | static var didStopBlockKey = "JDdidStopBlock" 25 | static var startedAnimationsKeysAssociated = "JDstartedAnimationsKeys" 26 | static var waitingToStartAnimationsKeysAssociated = "JDwaitingToStartAnimationsKeys" 27 | } 28 | 29 | public struct JDSpringConfig{ 30 | 31 | public var bounciness: CGFloat 32 | public var speed: CGFloat 33 | 34 | public init(bounciness: CGFloat, speed: CGFloat){ 35 | 36 | self.bounciness = bounciness 37 | self.speed = speed 38 | } 39 | 40 | public static func JDSpringConfigDefault() -> JDSpringConfig{ 41 | return JDSpringConfig(bounciness: 5, speed: 10) 42 | } 43 | } 44 | 45 | public struct JDAnimationConfig{ 46 | 47 | var duration: Double = 0.5 48 | } 49 | 50 | public typealias JDLayerAnimationStartBlock = (_ node: JDAnimationNode?, _ key: String?, _ finished: Bool?, _ error: NSError?) -> Void 51 | 52 | class ClosureLayerWrapper { 53 | var closure: JDLayerAnimationStartBlock! 54 | 55 | init(_ closure: JDLayerAnimationStartBlock!) { 56 | self.closure = closure 57 | } 58 | } 59 | 60 | // MARK: - Addons - 61 | 62 | extension Array where Element: Equatable { 63 | 64 | mutating func removeObject(_ object: Element) { 65 | if let index = self.index(of: object) { 66 | self.remove(at: index) 67 | } 68 | } 69 | 70 | mutating func removeObjectsInArray(_ array: [Element]) { 71 | for object in array { 72 | self.removeObject(object) 73 | } 74 | } 75 | } 76 | 77 | extension Double { 78 | 79 | func DegreesToRadians() -> Double { 80 | return self * M_PI / 180.0 81 | } 82 | 83 | func RadiansToDegrees() -> Double { 84 | return self * 180.0 / M_PI 85 | } 86 | } 87 | 88 | // MARK: - JDAnimationNode - 89 | 90 | public protocol JDAnimationNode : class{ 91 | 92 | var didStartBlock: JDLayerAnimationStartBlock? { get set } 93 | var didStopBlock: JDLayerAnimationStartBlock? { get set } 94 | 95 | var startedAnimationsKeys: [String]! {get set} 96 | var waitingToStartAnimationsKeys: [String]! {get set} 97 | 98 | func animatableLayer() -> CALayer 99 | 100 | @discardableResult func didStartAnimation(_ startBlock: JDLayerAnimationStartBlock?) -> JDAnimationNode 101 | @discardableResult func didStopAnimation(_ stopBlock: JDLayerAnimationStartBlock?) -> JDAnimationNode 102 | 103 | func makeGenericAnimation(_ property: String, toValue: AnyObject, duration: Double, delay: Double, spring: Bool, springConfig: JDSpringConfig, key: String, timing: JDTimingFunction) -> POPAnimation 104 | 105 | func makeChangeBounds(_ bounds: CGRect, duration: Double, spring: Bool, springConfig: JDSpringConfig, delay: Double, key: String, timing: JDTimingFunction) -> POPAnimation 106 | func changeBounds(_ bounds: CGRect, duration: Double, spring: Bool, springConfig: JDSpringConfig, delay: Double, key: String, timing: JDTimingFunction) -> JDAnimationNode 107 | 108 | func makeScaleTo(_ scaleX: CGFloat, scaleY: CGFloat, duration: Double, spring: Bool, springConfig: JDSpringConfig, delay: Double , key: String, timing: JDTimingFunction) -> POPAnimation 109 | func scaleXTo(_ scaleX: CGFloat, duration: Double , spring: Bool, springConfig: JDSpringConfig , delay: Double , key: String, timing: JDTimingFunction) -> JDAnimationNode 110 | func scaleYTo(_ scaleY: CGFloat, duration: Double , spring: Bool, springConfig: JDSpringConfig , delay: Double , key: String, timing: JDTimingFunction) -> JDAnimationNode 111 | func scaleTo(_ scaleX: CGFloat, scaleY: CGFloat, duration: Double , spring: Bool, springConfig: JDSpringConfig , delay: Double , key: String, timing: JDTimingFunction) -> JDAnimationNode 112 | 113 | func makeRotateTo(_ angle: Double, duration: Double , spring: Bool, springConfig: JDSpringConfig , delay: Double , key: String, timing: JDTimingFunction) -> POPAnimation 114 | func rotateTo(_ angle: Double, duration: Double , spring: Bool, springConfig: JDSpringConfig , delay: Double , key: String, timing: JDTimingFunction) -> JDAnimationNode 115 | 116 | func makeChangeBgColor(_ color: UIColor, duration: Double, spring: Bool, springConfig: JDSpringConfig, delay: Double, key: String, timing: JDTimingFunction) -> POPAnimation 117 | 118 | func changeBgColor(_ color: UIColor, duration: Double, spring: Bool, springConfig: JDSpringConfig, delay: Double, key: String, timing: JDTimingFunction) -> JDAnimationNode 119 | 120 | func makeOpacity(_ alpha: Double, duration: Double , spring: Bool, springConfig: JDSpringConfig , delay: Double , key: String, timing: JDTimingFunction) -> POPAnimation 121 | func opacityTo(_ alpha: Double, duration: Double , spring: Bool, springConfig: JDSpringConfig , delay: Double , key: String, timing: JDTimingFunction) -> JDAnimationNode 122 | 123 | func changeAnchorPoint(_ x: CGFloat, y: CGFloat, delay: Double) -> JDAnimationNode 124 | 125 | func moveXTo(_ x: CGFloat, duration: Double , spring: Bool, springConfig: JDSpringConfig , delay: Double , key: String, timing: JDTimingFunction) -> JDAnimationNode 126 | func moveYTo(_ y: CGFloat, duration: Double , spring: Bool, springConfig: JDSpringConfig , delay: Double , key: String, timing: JDTimingFunction) -> JDAnimationNode 127 | func moveTo(_ x: CGFloat, y: CGFloat, duration: Double , spring: Bool, springConfig: JDSpringConfig , delay: Double , key: String, timing: JDTimingFunction) -> JDAnimationNode 128 | 129 | func moveXBy(_ deltaX: CGFloat, duration: Double , spring: Bool , springConfig: JDSpringConfig , delay: Double , key: String, timing: JDTimingFunction) -> JDAnimationNode 130 | func moveYBy(_ deltaY: CGFloat, duration: Double , spring: Bool , springConfig: JDSpringConfig , delay: Double , key: String, timing: JDTimingFunction) -> JDAnimationNode 131 | func moveBy(_ deltaX: CGFloat, deltaY: CGFloat, duration: Double , spring: Bool , springConfig: JDSpringConfig , delay: Double , key: String, timing: JDTimingFunction) -> JDAnimationNode 132 | func makeMoveBy(_ deltaX: CGFloat, deltaY: CGFloat, duration: Double , delay: Double , spring: Bool , springConfig: JDSpringConfig , key: String, timing: JDTimingFunction) -> POPAnimation 133 | } 134 | 135 | // MARK: - Default implementation - 136 | 137 | extension JDAnimationNode{ 138 | 139 | // MARK: Properties 140 | 141 | public var startedAnimationsKeys: [String]! { 142 | get { 143 | if let keys = objc_getAssociatedObject(self.animatableLayer(), &JDAssociatedKeys.startedAnimationsKeysAssociated) as? [String] { 144 | return keys 145 | } 146 | 147 | return [String]() 148 | } 149 | set(newValue) { 150 | objc_setAssociatedObject(self.animatableLayer(), &JDAssociatedKeys.startedAnimationsKeysAssociated, newValue, .OBJC_ASSOCIATION_RETAIN) 151 | } 152 | } 153 | 154 | public var waitingToStartAnimationsKeys: [String]! { 155 | get { 156 | if let keys = objc_getAssociatedObject(self.animatableLayer(), &JDAssociatedKeys.waitingToStartAnimationsKeysAssociated) as? [String] { 157 | return keys 158 | } 159 | 160 | return [String]() 161 | } 162 | set(newValue) { 163 | objc_setAssociatedObject(self.animatableLayer(), &JDAssociatedKeys.waitingToStartAnimationsKeysAssociated, newValue, .OBJC_ASSOCIATION_RETAIN) 164 | } 165 | } 166 | 167 | public var didStartBlock: JDLayerAnimationStartBlock? { 168 | get { 169 | 170 | if let cl = objc_getAssociatedObject(self.animatableLayer(), &JDAssociatedKeys.didStartBlockKey) as? ClosureLayerWrapper { 171 | return cl.closure 172 | } 173 | return nil 174 | } 175 | 176 | set { 177 | objc_setAssociatedObject(self as? UIView, &JDAssociatedKeys.didStartBlockKey, ClosureLayerWrapper(newValue), .OBJC_ASSOCIATION_RETAIN_NONATOMIC) 178 | } 179 | } 180 | 181 | public var didStopBlock: JDLayerAnimationStartBlock? { 182 | get { 183 | 184 | if let cl = objc_getAssociatedObject(self.animatableLayer(), &JDAssociatedKeys.didStopBlockKey) as? ClosureLayerWrapper { 185 | return cl.closure 186 | } 187 | return nil 188 | } 189 | 190 | set { 191 | objc_setAssociatedObject(self.animatableLayer(), &JDAssociatedKeys.didStopBlockKey, ClosureLayerWrapper(newValue), .OBJC_ASSOCIATION_RETAIN_NONATOMIC) 192 | } 193 | } 194 | 195 | // MARK: Generic 196 | 197 | public func makeGenericAnimation(_ property: String, toValue: AnyObject, duration: Double, delay: Double = 0, spring: Bool = false, springConfig: JDSpringConfig = .JDSpringConfigDefault(), key: String, timing: JDTimingFunction) -> POPAnimation { 198 | 199 | if spring { 200 | 201 | let animation = (POPSpringAnimation(propertyNamed: property) as POPSpringAnimation) 202 | animation.springBounciness = springConfig.bounciness 203 | animation.springSpeed = springConfig.speed 204 | animation.toValue = toValue 205 | animation.beginTime = (CACurrentMediaTime() + delay) 206 | animation.delegate = self.animatableLayer() 207 | animation.name = key 208 | 209 | return animation 210 | 211 | } else { 212 | 213 | let animation = POPBasicAnimation(propertyNamed: property) 214 | animation?.duration = duration 215 | animation?.toValue = toValue 216 | animation?.beginTime = (CACurrentMediaTime() + delay) 217 | animation?.delegate = self.animatableLayer() 218 | animation?.name = key 219 | animation?.timingFunction = self._timingFunctionKey(timing) 220 | 221 | return animation! 222 | } 223 | } 224 | 225 | public func animatableLayer() -> CALayer{ 226 | return self as! CALayer 227 | } 228 | 229 | // MARK: Private 230 | 231 | internal func _timingFunctionKey(_ timing: JDTimingFunction) -> CAMediaTimingFunction{ 232 | 233 | switch timing{ 234 | 235 | case .easeIn: 236 | return CAMediaTimingFunction(name:kCAMediaTimingFunctionEaseIn) 237 | case .easeOut: 238 | return CAMediaTimingFunction(name:kCAMediaTimingFunctionEaseOut) 239 | case .easeInOut: 240 | return CAMediaTimingFunction(name:kCAMediaTimingFunctionEaseInEaseOut) 241 | case .linear: 242 | return CAMediaTimingFunction(name:kCAMediaTimingFunctionLinear) 243 | case .none: 244 | return CAMediaTimingFunction(name:kCAMediaTimingFunctionDefault) 245 | } 246 | } 247 | 248 | internal func _executeAfter(_ delay: Double, closure: @escaping ()->()) { 249 | DispatchQueue.main.asyncAfter( 250 | deadline: DispatchTime.now() + Double(Int64(delay * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC), 251 | execute: closure 252 | ) 253 | } 254 | 255 | @discardableResult internal func _addAnimation(_ animation: POPAnimation, key: String) -> JDAnimationNode{ 256 | 257 | self.waitingToStartAnimationsKeys.append(key) 258 | self.startedAnimationsKeys.append(key) 259 | 260 | self.animatableLayer().pop_add(animation, forKey: key) 261 | 262 | return self 263 | } 264 | 265 | // MARK: Change Bounds 266 | 267 | public func makeChangeBounds(_ bounds: CGRect, duration: Double = 0.5, spring: Bool = false, springConfig: JDSpringConfig = .JDSpringConfigDefault(), delay: Double = 0, key: String = "changeBound", timing: JDTimingFunction = .none) -> POPAnimation { 268 | 269 | return self.makeGenericAnimation(kPOPLayerBounds, toValue: NSValue(cgRect: bounds), duration: duration, delay: delay, spring: spring, springConfig: springConfig, key: key, timing: timing) 270 | } 271 | 272 | public func changeBounds(_ bounds: CGRect, duration: Double = 0.5, spring: Bool = false, springConfig: JDSpringConfig = .JDSpringConfigDefault(), delay: Double = 0, key: String = "changeBound", timing: JDTimingFunction = .none) -> JDAnimationNode { 273 | 274 | let frameAnimation = makeChangeBounds(bounds, duration: duration, spring: spring, springConfig: springConfig, delay: delay, key: key, timing: timing) 275 | 276 | self._addAnimation(frameAnimation, key: frameAnimation.name) 277 | 278 | return self 279 | } 280 | 281 | // MARK: ScaleTo 282 | 283 | public func makeScaleTo(_ scaleX: CGFloat, scaleY: CGFloat, duration: Double = 0.5, spring: Bool = false, springConfig: JDSpringConfig = .JDSpringConfigDefault(), delay: Double = 0, key: String = "scaleTo", timing: JDTimingFunction = .none) -> POPAnimation { 284 | 285 | return self.makeGenericAnimation(kPOPLayerScaleXY, toValue: NSValue(cgPoint: CGPoint(x: scaleX, y: scaleY)), duration: duration, delay: delay, spring: spring, springConfig: springConfig, key: key, timing: timing) 286 | } 287 | 288 | public func scaleXTo(_ scaleX: CGFloat, duration: Double = 0.5, spring: Bool = false, springConfig: JDSpringConfig = .JDSpringConfigDefault(), delay: Double = 0, key: String = "scaleXTo", timing: JDTimingFunction = .none) -> JDAnimationNode { 289 | 290 | return self.scaleTo(scaleX, scaleY: 1, duration: duration, spring: spring, springConfig: springConfig, delay: delay, key: key, timing: timing) 291 | } 292 | 293 | public func scaleYTo(_ scaleY: CGFloat, duration: Double = 0.5, spring: Bool = false, springConfig: JDSpringConfig = .JDSpringConfigDefault(), delay: Double = 0, key: String = "scaleYTo", timing: JDTimingFunction = .none) -> JDAnimationNode { 294 | 295 | return self.scaleTo(1, scaleY: scaleY, duration: duration, spring: spring, springConfig: springConfig, delay: delay, key: key, timing: timing) 296 | } 297 | 298 | public func scaleTo(_ scaleX: CGFloat, scaleY: CGFloat,duration: Double = 0.5, spring: Bool = false, springConfig: JDSpringConfig = .JDSpringConfigDefault(), delay: Double = 0, key: String = "scaleTo", timing: JDTimingFunction = .none) -> JDAnimationNode { 299 | 300 | let scaleAnimation = makeScaleTo(scaleX, scaleY: scaleY, duration: duration, spring: spring, springConfig: springConfig, delay: delay, key: key, timing: timing) 301 | 302 | self._addAnimation(scaleAnimation, key: scaleAnimation.name) 303 | 304 | return self 305 | } 306 | 307 | // MARK: RotateTo 308 | 309 | public func makeRotateTo(_ angle: Double, duration: Double = 0.5, spring: Bool = false, springConfig: JDSpringConfig = .JDSpringConfigDefault(), delay: Double = 0, key: String = "rotateTo", timing: JDTimingFunction = .none) -> POPAnimation { 310 | 311 | return self.makeGenericAnimation(kPOPLayerRotation, toValue: CGFloat(angle.DegreesToRadians()) as AnyObject, duration: duration, delay: delay, spring: spring, springConfig: springConfig, key: key, timing: timing) 312 | } 313 | 314 | public func rotateTo(_ angle: Double, duration: Double = 0.5, spring: Bool = false, springConfig: JDSpringConfig = .JDSpringConfigDefault(), delay: Double = 0, key: String = "rotateTo", timing: JDTimingFunction = .none) -> JDAnimationNode { 315 | 316 | let rotateAnimation = makeRotateTo(angle, duration: duration, spring: spring, springConfig: springConfig, delay: delay, key: key, timing: timing) 317 | 318 | self._addAnimation(rotateAnimation, key: rotateAnimation.name) 319 | 320 | return self 321 | } 322 | 323 | // MARK: BackgroundColor 324 | 325 | public func makeChangeBgColor(_ color: UIColor, duration: Double = 0.5, spring: Bool = false, springConfig: JDSpringConfig = .JDSpringConfigDefault(), delay: Double = 0, key: String = "backgroundTo", timing: JDTimingFunction = .none) -> POPAnimation { 326 | return self.makeGenericAnimation(kPOPLayerBackgroundColor, toValue: color, duration: duration, delay: delay, spring: spring, springConfig: springConfig, key: key, timing: timing) 327 | } 328 | 329 | public func changeBgColor(_ color: UIColor, duration: Double = 0.5, spring: Bool = false, springConfig: JDSpringConfig = .JDSpringConfigDefault(), delay: Double = 0, key: String = "backgroundTo", timing: JDTimingFunction = .none) -> JDAnimationNode { 330 | 331 | let backgroundAnimation = makeChangeBgColor(color, duration: duration, spring: spring, springConfig: springConfig, delay: delay, key: key, timing: timing) 332 | 333 | self._addAnimation(backgroundAnimation, key: backgroundAnimation.name) 334 | 335 | return self 336 | } 337 | 338 | // MARK: Opacity 339 | 340 | public func makeOpacity(_ alpha: Double, duration: Double = 0.5, spring: Bool = false, springConfig: JDSpringConfig = .JDSpringConfigDefault(), delay: Double = 0, key: String = "opacityTo", timing: JDTimingFunction = .none) -> POPAnimation { 341 | return self.makeGenericAnimation(kPOPLayerOpacity, toValue: CGFloat(alpha) as AnyObject, duration: duration, delay: delay, spring: spring, springConfig: springConfig, key: key, timing: timing) 342 | } 343 | 344 | public func opacityTo(_ alpha: Double, duration: Double = 0.5, spring: Bool = false, springConfig: JDSpringConfig = .JDSpringConfigDefault(), delay: Double = 0, key: String = "opacityTo", timing: JDTimingFunction = .none) -> JDAnimationNode { 345 | 346 | let alphaAnimation = makeOpacity(alpha, duration: duration, spring: spring, springConfig: springConfig, delay: delay, key: key, timing: timing) 347 | 348 | self._addAnimation(alphaAnimation, key: alphaAnimation.name) 349 | 350 | return self 351 | } 352 | 353 | // MARK: Anchor point 354 | 355 | public func changeAnchorPoint(_ x: CGFloat, y: CGFloat, delay: Double = 0) -> JDAnimationNode{ 356 | 357 | self._executeAfter(delay) { () -> () in 358 | 359 | let anchorPoint = CGPoint(x: x, y: y) 360 | 361 | var newPoint = CGPoint(x: self.animatableLayer().bounds.size.width * anchorPoint.x, y: self.animatableLayer().bounds.size.height * anchorPoint.y) 362 | var oldPoint = CGPoint(x: self.animatableLayer().bounds.size.width * self.animatableLayer().anchorPoint.x, y: self.animatableLayer().bounds.size.height * self.animatableLayer().anchorPoint.y) 363 | 364 | newPoint = newPoint.applying(self.animatableLayer().affineTransform()) 365 | oldPoint = newPoint.applying(self.animatableLayer().affineTransform()) 366 | 367 | var position = self.animatableLayer().position 368 | position.x -= oldPoint.x 369 | position.x += newPoint.x 370 | 371 | position.y -= oldPoint.y 372 | position.y += newPoint.y 373 | 374 | self.animatableLayer().position = position 375 | self.animatableLayer().anchorPoint = anchorPoint 376 | } 377 | 378 | return self 379 | } 380 | 381 | // MARK: Move To 382 | 383 | public func moveXTo(_ x: CGFloat, duration: Double = 0.5, spring: Bool = false, springConfig: JDSpringConfig = .JDSpringConfigDefault(), delay: Double = 0, key: String = "moveXTo", timing: JDTimingFunction = .none) -> JDAnimationNode { 384 | 385 | return self.moveTo(x, y: self.animatableLayer().position.y, duration: duration, spring: spring, springConfig: springConfig, delay: delay, key: key, timing: timing) 386 | } 387 | 388 | 389 | public func moveYTo(_ y: CGFloat, duration: Double = 0.5, spring: Bool = false, springConfig: JDSpringConfig = .JDSpringConfigDefault(), delay: Double = 0, key: String = "moveYTo", timing: JDTimingFunction = .none) -> JDAnimationNode { 390 | 391 | return self.moveTo(self.animatableLayer().position.x, y: y, duration: duration, spring: spring, springConfig: springConfig, delay: delay, key: key, timing: timing) 392 | } 393 | 394 | public func moveTo(_ x: CGFloat, y: CGFloat, duration: Double = 0.5, spring: Bool = false, springConfig: JDSpringConfig = .JDSpringConfigDefault(), delay: Double = 0, key: String = "moveTo", timing: JDTimingFunction = .none) -> JDAnimationNode { 395 | 396 | let moveAnimation = makeMoveTo(x, y: y, duration: duration, delay: delay, spring: spring, springConfig: springConfig, key: key, timing: timing) 397 | 398 | self._addAnimation(moveAnimation, key: moveAnimation.name) 399 | 400 | return self 401 | } 402 | 403 | public func makeMoveTo(_ x: CGFloat, y: CGFloat, duration: Double = 0.5, delay: Double = 0, spring: Bool = false, springConfig: JDSpringConfig = .JDSpringConfigDefault(), key: String = "moveTo", timing: JDTimingFunction = .none) -> POPAnimation { 404 | 405 | return self.makeGenericAnimation(kPOPLayerPosition, toValue: NSValue(cgPoint: CGPoint(x: x, y: y)), duration: duration, delay: delay, spring: spring, springConfig: springConfig, key: key, timing: timing) 406 | } 407 | 408 | // MARK: Move By 409 | 410 | public func moveXBy(_ deltaX: CGFloat, duration: Double = 0.5, spring: Bool = false, springConfig: JDSpringConfig = .JDSpringConfigDefault(), delay: Double = 0, key: String = "moveXBy", timing: JDTimingFunction = .none) -> JDAnimationNode { 411 | 412 | return self.moveBy(deltaX, deltaY: 0, duration: duration, spring: spring, springConfig: springConfig, delay: delay, key: key, timing: timing) 413 | } 414 | 415 | 416 | public func moveYBy(_ deltaY: CGFloat, duration: Double = 0.5, spring: Bool = false, springConfig: JDSpringConfig = .JDSpringConfigDefault(), delay: Double = 0, key: String = "moveYBy", timing: JDTimingFunction = .none) -> JDAnimationNode { 417 | 418 | return self.moveBy(0, deltaY: deltaY, duration: duration, spring: spring, springConfig: springConfig, delay: delay, key: key, timing: timing) 419 | } 420 | 421 | public func moveBy(_ deltaX: CGFloat, deltaY: CGFloat, duration: Double = 0.5, spring: Bool = false, springConfig: JDSpringConfig = .JDSpringConfigDefault(), delay: Double = 0, key: String = "moveBy", timing: JDTimingFunction = .none) -> JDAnimationNode { 422 | 423 | let moveAnimation = makeMoveBy(deltaX, deltaY: deltaY, duration: duration, delay: delay, spring: spring, springConfig: springConfig, key: key, timing: timing) 424 | 425 | self._addAnimation(moveAnimation, key: moveAnimation.name) 426 | 427 | return self 428 | } 429 | 430 | public func makeMoveBy(_ deltaX: CGFloat, deltaY: CGFloat, duration: Double = 0.5, delay: Double = 0, spring: Bool = false, springConfig: JDSpringConfig = .JDSpringConfigDefault(), key: String = "moveBy", timing: JDTimingFunction = .none) -> POPAnimation { 431 | 432 | var nextPosition = self.animatableLayer().position 433 | nextPosition.x += deltaX 434 | nextPosition.y += deltaY 435 | 436 | return self.makeGenericAnimation(kPOPLayerPosition, toValue: NSValue(cgPoint: nextPosition), duration: duration, delay: delay, spring: spring, springConfig: springConfig, key: key, timing: timing) 437 | } 438 | 439 | // MARK: Callback 440 | 441 | public func didStartAnimation(_ startBlock: JDLayerAnimationStartBlock?) -> JDAnimationNode { 442 | 443 | self.animatableLayer().didStartBlock = startBlock 444 | 445 | return self 446 | } 447 | 448 | public func didStopAnimation(_ stopBlock: JDLayerAnimationStartBlock?) -> JDAnimationNode { 449 | 450 | self.animatableLayer().didStopBlock = stopBlock 451 | 452 | return self 453 | } 454 | } 455 | 456 | // MARK: - POPAnimation Delegate - 457 | 458 | extension CALayer : POPAnimationDelegate { 459 | 460 | public func pop_animationDidStart(_ anim: POPAnimation!) { 461 | 462 | self.waitingToStartAnimationsKeys.removeObject(anim.name) 463 | 464 | guard self.didStartBlock != nil else { 465 | return 466 | } 467 | 468 | let block = self.didStartBlock 469 | 470 | if self.waitingToStartAnimationsKeys.count == 0{ 471 | self.didStartAnimation(nil) 472 | } 473 | 474 | block!(self, anim.name, (self.startedAnimationsKeys.count == 0), nil) 475 | } 476 | 477 | public func pop_animationDidStop(_ anim: POPAnimation!, finished: Bool) { 478 | 479 | self.startedAnimationsKeys.removeObject(anim.name) 480 | 481 | guard self.didStopBlock != nil else { 482 | return 483 | } 484 | 485 | let block = self.didStopBlock 486 | 487 | if self.startedAnimationsKeys.count == 0{ 488 | self.didStopAnimation(nil) 489 | } 490 | 491 | block!(self, anim.name, (self.startedAnimationsKeys.count == 0), nil) 492 | } 493 | } 494 | 495 | // MARK: - Cocoa Objects Animable - 496 | 497 | extension CALayer : JDAnimationNode {} 498 | 499 | extension UIView : JDAnimationNode{ 500 | 501 | public func animatableLayer() -> CALayer{ 502 | return self.layer 503 | } 504 | 505 | public func changeAnchorPoint(_ x: CGFloat, y: CGFloat, delay: Double = 0) -> JDAnimationNode{ 506 | 507 | self._executeAfter(delay) { () -> () in 508 | 509 | let anchorPoint = CGPoint(x: x, y: y) 510 | 511 | var newPoint = CGPoint(x: self.bounds.size.width * anchorPoint.x, y: self.bounds.size.height * anchorPoint.y) 512 | var oldPoint = CGPoint(x: self.bounds.size.width * self.animatableLayer().anchorPoint.x, y: self.bounds.size.height * self.animatableLayer().anchorPoint.y) 513 | 514 | newPoint = newPoint.applying(self.transform) 515 | oldPoint = oldPoint.applying(self.transform) 516 | 517 | var position = self.animatableLayer().position 518 | position.x -= oldPoint.x 519 | position.x += newPoint.x 520 | 521 | position.y -= oldPoint.y 522 | position.y += newPoint.y 523 | 524 | self.animatableLayer().position = position 525 | self.animatableLayer().anchorPoint = anchorPoint 526 | } 527 | 528 | return self 529 | } 530 | } 531 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![](http://juanpecatalan.com/JDAnimationKit/JDAnimationKit_header_2.jpg) 2 | 3 | [![BuddyBuild](https://dashboard.buddybuild.com/api/statusImage?appID=58a576b862e30f010053f46c&branch=master&build=latest)](https://dashboard.buddybuild.com/apps/58a576b862e30f010053f46c/build/latest?branch=master) 4 | [![codebeat badge](https://codebeat.co/badges/de5febf0-da2a-44ee-b2f9-f0bdd9bf5441)](https://codebeat.co/projects/github-com-juanpe-jdanimationkit) 5 | [![Version](https://img.shields.io/cocoapods/v/JDAnimationKit.svg?style=flat)](http://cocoapods.org/pods/JDAnimationKit) 6 | [![Platform](https://img.shields.io/badge/platform-iOS-blue.svg?style=flat)](http://cocoapods.org/pods/JDAnimationKit) 7 | [![Swift3](https://img.shields.io/badge/Swift-3.0-orange.svg?style=flat)](https://developer.apple.com/swift) 8 | [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat)](http://cocoapods.org/pods/JDAnimationKit) 9 | [![CocoaPods](https://img.shields.io/cocoapods/dt/JDAnimationKit.svg)](https://cocoapods.org/pods/JDAnimationKit) [![CocoaPods](https://img.shields.io/cocoapods/dm/JDAnimationKit.svg)](https://cocoapods.org/pods/JDAnimationKit) 10 | 11 | 12 | **JDAnimationKit** is designed to be extremely easy to use. You can animate your UI withe less lines of code. This library use internally [POP](https://github.com/facebook/pop) framework, an extensible iOS and OS X animation library, useful for physics-based interactions. 13 | 14 | ### Supported OS & SDK Versions 15 | 16 | * iOS 8.0+ 17 | * Swift 3 (JDAnimationKit 1.0.x), Swift 2.3 (JDAnimationKit 1.1.x) 18 | 19 | ### Demo 20 | 21 | ![Preview](http://juanpecatalan.com/JDAnimationKit/beetripper_1.gif) 22 | ![Preview](http://juanpecatalan.com/JDAnimationKit/beetripper_2.gif) 23 | ###### 24 | *[Beetripper App's screenshots](http://beetripper.com)* 25 | 26 | #### 27 | 28 | 29 | 30 | 33 | 36 | 38 | 41 | 44 | 45 |
31 | 32 | 34 | 35 |
39 | 40 | 42 | 43 |
46 | 47 | ## Installation 48 | 49 | JDAnimationKit is available through [CocoaPods](http://cocoapods.org). To install 50 | it, simply add the following line to your Podfile: 51 | 52 | ```ruby 53 | pod "JDAnimationKit" 54 | ``` 55 | 56 | Note: Due to [CocoaPods/CocoaPods#4420 issue](https://github.com/CocoaPods/CocoaPods/issues/4420) there is problem with compiling project with Xcode 7.1 and CocoaPods v0.39.0. However there is a temporary workaround for this: 57 | Add next lines to the end of your Podfile 58 | ```ruby 59 | post_install do |installer| 60 | `find Pods -regex 'Pods/pop.*\\.h' -print0 | xargs -0 sed -i '' 's/\\(<\\)pop\\/\\(.*\\)\\(>\\)/\\"\\2\\"/'` 61 | end 62 | ``` 63 | To install manually the JDAnimationKit class in an app, just drag the ``` JDAnimationKit.swift``` class file (demo files and assets are not needed) into your project. Also you need to install facebook-pop. Or add bridging header if you are using CocoaPods. 64 | 65 | ## Usage 66 | 67 | Import JDAnimationKit in proper place. 68 | ```swift 69 | import JDAnimationKit 70 | ``` 71 | 72 | You can animate **CALayers** and **UIViews** (and subclasses). Only you add the animation you want after element. 73 | ```swift 74 | self.squareView.rotateTo(90) 75 | ``` 76 | 77 | If you want mutiple animation at one time. 78 | ```swift 79 | self.squareView.rotateTo(90).moveXBy(50).opacityTo(0) 80 | ``` 81 | 82 | All methods have got more arguments with default values. You don't need indicate all, only the params that your need. 83 | 84 | ```swift 85 | self.squareView.rotateTo(90).moveXBy(50, delay: 2.0, timing: .EaseIn) 86 | ``` 87 | 88 | ## Configure your animations 89 | 90 | You can adjust the parameters of your animations: 91 | #### -> duration : *Double* 92 | Indicate the duration of animation *(Default: 0.5)* 93 | 94 | #### -> spring : *Bool* 95 | Indicate if apply physics effects to animate *(Default: false)* 96 | 97 | #### -> springConfig : *JDSpringConfig (struct)* 98 | If ```spring``` property is ```true```, configure the physics params (```bounciness``` and ```speed```) *(Default: bounciness: 10, speed: 10)* 99 | 100 | #### -> timing : *JDTimingFunction (enum)* 101 | The animation-timing-function specifies the speed curve of an animation *(Default: .None)* 102 | 103 | **Values:** 104 | * EaseIn 105 | * EaseOut 106 | * EaseInOut 107 | * Linear 108 | * None 109 | 110 | #### -> delay : *Double* 111 | You can execute the animation after X seconds. *(Default: 0)* 112 | 113 | #### -> key : *String* 114 | Identify the animation 115 | 116 | ## Anchoring 117 | 118 | The anchor point represents the point from which certain coordinates originate. The anchor point is one of several properties that you specify using the unit coordinate system. Core Animation uses unit coordinates to represent properties whose values might change when the layer’s size changes. You can think of the unit coordinates as specifying a percentage of the total possible value. Every coordinate in the unit coordinate space has a range of 0.0 to 1.0. For example, along the x-axis, the left edge is at the coordinate 0.0 and the right edge is at the coordinate 1.0. 119 | 120 | ![Preview](https://c1.staticflickr.com/9/8164/7525485756_6782ed8ce6.jpg) 121 | 122 | You can set the anchor point with this code: 123 | 124 | ```swift 125 | self.squareView.changeAnchorPoint(0, y: 0) 126 | ``` 127 | 128 | ## Callback 129 | 130 | If you want to get animations callbacks or if you want to run code after an animation finishes, you are supposed to call didStopAnimation or didStartAnimation block. 131 | ```swift 132 | self.squareView.scaleTo(2, scaleY: 2).didStartAnimation { (node, key, finished, error) -> Void in 133 | 134 | } 135 | ``` 136 | ```swift 137 | self.squareView.scaleTo(2, scaleY: 2).didStopAnimation { (node, key, finished, error) -> Void in 138 | 139 | } 140 | ``` 141 | 142 | ## Chainable Animations 143 | 144 | 145 | 146 | 147 | 150 | 153 | 154 | 155 | 156 | 159 | 162 | 163 | 164 | 165 | 168 | 171 | 172 | 173 | 174 | 177 | 180 | 181 | 182 | 183 | 186 | 189 | 190 | 191 | 192 | 195 | 198 | 199 | 200 | 201 | 204 | 207 | 208 | 209 | 210 | 213 | 216 | 217 | 218 | 219 | 222 | 225 | 226 | 227 | 228 | 231 | 234 | 235 | 236 | 237 | 240 | 243 | 244 | 245 | 246 | 249 | 252 | 253 | 254 | 255 | 258 | 261 | 262 | 263 |
148 | 149 | 151 | self.squareView.moveXTo(100) 152 |
157 | 158 | 160 | self.squareView.moveYTo(100) 161 |
166 | 167 | 169 | self.squareView.moveTo(100, y: 100) 170 |
175 | 176 | 178 | self.squareView.moveXBy(100) 179 |
184 | 185 | 187 | self.squareView.moveYBy(50) 188 |
193 | 194 | 196 | self.squareView.moveBy(100, deltaY: 50) 197 |
202 | 203 | 205 | self.squareView.scaleXTo(2) 206 |
211 | 212 | 214 | self.squareView.scaleYTo(2) 215 |
220 | 221 | 223 | self.squareView.scaleTo(2, scaleY: 2) 224 |
229 | 230 | 232 | self.squareView.opacityTo(0) 233 |
238 | 239 | 241 | self.squareView.rotateTo(90) 242 |
247 | 248 | 250 | self.squareView.changeBounds(bounds) //let bounds: CGRect 251 |
256 | 257 | 259 | self.squareView.changeBgColor(green) //let green: UIColor 260 |
264 | 265 | ## Author 266 | 267 | * [Jelly Development](https://github.com/JellyDevelopment) 268 | * Juanpe Catalán, juanpecm@gmail.com 269 | * David López Carrascal, davidlcarrascal@gmail.com 270 | 271 | ## License 272 | 273 | JDAnimationKit is available under the MIT license. See the LICENSE file for more info. 274 | -------------------------------------------------------------------------------- /_Pods.xcodeproj: -------------------------------------------------------------------------------- 1 | Example/Pods/Pods.xcodeproj --------------------------------------------------------------------------------