├── .gitignore ├── Demo.xcodeproj └── project.pbxproj ├── Demo ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json ├── Base.lproj │ └── LaunchScreen.storyboard ├── Info.plist └── ViewController.swift ├── Images ├── SequenceAnimatorComparison.gif └── SequenceDemo.gif ├── LICENSE ├── README.md └── SequenceAnimator.swift /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | ## Playgrounds 32 | timeline.xctimeline 33 | playground.xcworkspace 34 | 35 | # Swift Package Manager 36 | # 37 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 38 | # Packages/ 39 | # Package.pins 40 | # Package.resolved 41 | .build/ 42 | 43 | # CocoaPods 44 | # 45 | # We recommend against adding the Pods directory to your .gitignore. However 46 | # you should judge for yourself, the pros and cons are mentioned at: 47 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 48 | # 49 | # Pods/ 50 | 51 | # Carthage 52 | # 53 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 54 | # Carthage/Checkouts 55 | 56 | Carthage/Build 57 | 58 | # fastlane 59 | # 60 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 61 | # screenshots whenever they are needed. 62 | # For more information about the recommended setup visit: 63 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 64 | 65 | fastlane/report.xml 66 | fastlane/Preview.html 67 | fastlane/screenshots/**/*.png 68 | fastlane/test_output 69 | -------------------------------------------------------------------------------- /Demo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | DB357E7D228D37C30009B88B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB357E7C228D37C30009B88B /* AppDelegate.swift */; }; 11 | DB357E7F228D37C30009B88B /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB357E7E228D37C30009B88B /* ViewController.swift */; }; 12 | DB357E84228D37C30009B88B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DB357E83228D37C30009B88B /* Assets.xcassets */; }; 13 | DB357E87228D37C30009B88B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DB357E85228D37C30009B88B /* LaunchScreen.storyboard */; }; 14 | DB357E8F228D37DD0009B88B /* SequenceAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB357E8E228D37DD0009B88B /* SequenceAnimator.swift */; }; 15 | /* End PBXBuildFile section */ 16 | 17 | /* Begin PBXFileReference section */ 18 | DB357E79228D37C30009B88B /* Demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Demo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 19 | DB357E7C228D37C30009B88B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 20 | DB357E7E228D37C30009B88B /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 21 | DB357E83228D37C30009B88B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 22 | DB357E86228D37C30009B88B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 23 | DB357E88228D37C30009B88B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 24 | DB357E8E228D37DD0009B88B /* SequenceAnimator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SequenceAnimator.swift; sourceTree = ""; }; 25 | /* End PBXFileReference section */ 26 | 27 | /* Begin PBXFrameworksBuildPhase section */ 28 | DB357E76228D37C30009B88B /* Frameworks */ = { 29 | isa = PBXFrameworksBuildPhase; 30 | buildActionMask = 2147483647; 31 | files = ( 32 | ); 33 | runOnlyForDeploymentPostprocessing = 0; 34 | }; 35 | /* End PBXFrameworksBuildPhase section */ 36 | 37 | /* Begin PBXGroup section */ 38 | DB357E70228D37C30009B88B = { 39 | isa = PBXGroup; 40 | children = ( 41 | DB357E8E228D37DD0009B88B /* SequenceAnimator.swift */, 42 | DB357E7B228D37C30009B88B /* Demo */, 43 | DB357E7A228D37C30009B88B /* Products */, 44 | ); 45 | sourceTree = ""; 46 | }; 47 | DB357E7A228D37C30009B88B /* Products */ = { 48 | isa = PBXGroup; 49 | children = ( 50 | DB357E79228D37C30009B88B /* Demo.app */, 51 | ); 52 | name = Products; 53 | sourceTree = ""; 54 | }; 55 | DB357E7B228D37C30009B88B /* Demo */ = { 56 | isa = PBXGroup; 57 | children = ( 58 | DB357E7C228D37C30009B88B /* AppDelegate.swift */, 59 | DB357E7E228D37C30009B88B /* ViewController.swift */, 60 | DB357E83228D37C30009B88B /* Assets.xcassets */, 61 | DB357E85228D37C30009B88B /* LaunchScreen.storyboard */, 62 | DB357E88228D37C30009B88B /* Info.plist */, 63 | ); 64 | path = Demo; 65 | sourceTree = ""; 66 | }; 67 | /* End PBXGroup section */ 68 | 69 | /* Begin PBXNativeTarget section */ 70 | DB357E78228D37C30009B88B /* Demo */ = { 71 | isa = PBXNativeTarget; 72 | buildConfigurationList = DB357E8B228D37C30009B88B /* Build configuration list for PBXNativeTarget "Demo" */; 73 | buildPhases = ( 74 | DB357E75228D37C30009B88B /* Sources */, 75 | DB357E76228D37C30009B88B /* Frameworks */, 76 | DB357E77228D37C30009B88B /* Resources */, 77 | ); 78 | buildRules = ( 79 | ); 80 | dependencies = ( 81 | ); 82 | name = Demo; 83 | productName = Demo; 84 | productReference = DB357E79228D37C30009B88B /* Demo.app */; 85 | productType = "com.apple.product-type.application"; 86 | }; 87 | /* End PBXNativeTarget section */ 88 | 89 | /* Begin PBXProject section */ 90 | DB357E71228D37C30009B88B /* Project object */ = { 91 | isa = PBXProject; 92 | attributes = { 93 | LastSwiftUpdateCheck = 1020; 94 | LastUpgradeCheck = 1020; 95 | ORGANIZATIONNAME = "Two Lives Left"; 96 | TargetAttributes = { 97 | DB357E78228D37C30009B88B = { 98 | CreatedOnToolsVersion = 10.2; 99 | }; 100 | }; 101 | }; 102 | buildConfigurationList = DB357E74228D37C30009B88B /* Build configuration list for PBXProject "Demo" */; 103 | compatibilityVersion = "Xcode 9.3"; 104 | developmentRegion = en; 105 | hasScannedForEncodings = 0; 106 | knownRegions = ( 107 | en, 108 | Base, 109 | ); 110 | mainGroup = DB357E70228D37C30009B88B; 111 | productRefGroup = DB357E7A228D37C30009B88B /* Products */; 112 | projectDirPath = ""; 113 | projectRoot = ""; 114 | targets = ( 115 | DB357E78228D37C30009B88B /* Demo */, 116 | ); 117 | }; 118 | /* End PBXProject section */ 119 | 120 | /* Begin PBXResourcesBuildPhase section */ 121 | DB357E77228D37C30009B88B /* Resources */ = { 122 | isa = PBXResourcesBuildPhase; 123 | buildActionMask = 2147483647; 124 | files = ( 125 | DB357E87228D37C30009B88B /* LaunchScreen.storyboard in Resources */, 126 | DB357E84228D37C30009B88B /* Assets.xcassets in Resources */, 127 | ); 128 | runOnlyForDeploymentPostprocessing = 0; 129 | }; 130 | /* End PBXResourcesBuildPhase section */ 131 | 132 | /* Begin PBXSourcesBuildPhase section */ 133 | DB357E75228D37C30009B88B /* Sources */ = { 134 | isa = PBXSourcesBuildPhase; 135 | buildActionMask = 2147483647; 136 | files = ( 137 | DB357E7F228D37C30009B88B /* ViewController.swift in Sources */, 138 | DB357E7D228D37C30009B88B /* AppDelegate.swift in Sources */, 139 | DB357E8F228D37DD0009B88B /* SequenceAnimator.swift in Sources */, 140 | ); 141 | runOnlyForDeploymentPostprocessing = 0; 142 | }; 143 | /* End PBXSourcesBuildPhase section */ 144 | 145 | /* Begin PBXVariantGroup section */ 146 | DB357E85228D37C30009B88B /* LaunchScreen.storyboard */ = { 147 | isa = PBXVariantGroup; 148 | children = ( 149 | DB357E86228D37C30009B88B /* Base */, 150 | ); 151 | name = LaunchScreen.storyboard; 152 | sourceTree = ""; 153 | }; 154 | /* End PBXVariantGroup section */ 155 | 156 | /* Begin XCBuildConfiguration section */ 157 | DB357E89228D37C30009B88B /* Debug */ = { 158 | isa = XCBuildConfiguration; 159 | buildSettings = { 160 | ALWAYS_SEARCH_USER_PATHS = NO; 161 | CLANG_ANALYZER_NONNULL = YES; 162 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 163 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 164 | CLANG_CXX_LIBRARY = "libc++"; 165 | CLANG_ENABLE_MODULES = YES; 166 | CLANG_ENABLE_OBJC_ARC = YES; 167 | CLANG_ENABLE_OBJC_WEAK = YES; 168 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 169 | CLANG_WARN_BOOL_CONVERSION = YES; 170 | CLANG_WARN_COMMA = YES; 171 | CLANG_WARN_CONSTANT_CONVERSION = YES; 172 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 173 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 174 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 175 | CLANG_WARN_EMPTY_BODY = YES; 176 | CLANG_WARN_ENUM_CONVERSION = YES; 177 | CLANG_WARN_INFINITE_RECURSION = YES; 178 | CLANG_WARN_INT_CONVERSION = YES; 179 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 180 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 181 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 182 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 183 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 184 | CLANG_WARN_STRICT_PROTOTYPES = YES; 185 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 186 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 187 | CLANG_WARN_UNREACHABLE_CODE = YES; 188 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 189 | CODE_SIGN_IDENTITY = "iPhone Developer"; 190 | COPY_PHASE_STRIP = NO; 191 | DEBUG_INFORMATION_FORMAT = dwarf; 192 | ENABLE_STRICT_OBJC_MSGSEND = YES; 193 | ENABLE_TESTABILITY = YES; 194 | GCC_C_LANGUAGE_STANDARD = gnu11; 195 | GCC_DYNAMIC_NO_PIC = NO; 196 | GCC_NO_COMMON_BLOCKS = YES; 197 | GCC_OPTIMIZATION_LEVEL = 0; 198 | GCC_PREPROCESSOR_DEFINITIONS = ( 199 | "DEBUG=1", 200 | "$(inherited)", 201 | ); 202 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 203 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 204 | GCC_WARN_UNDECLARED_SELECTOR = YES; 205 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 206 | GCC_WARN_UNUSED_FUNCTION = YES; 207 | GCC_WARN_UNUSED_VARIABLE = YES; 208 | IPHONEOS_DEPLOYMENT_TARGET = 12.2; 209 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 210 | MTL_FAST_MATH = YES; 211 | ONLY_ACTIVE_ARCH = YES; 212 | SDKROOT = iphoneos; 213 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 214 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 215 | }; 216 | name = Debug; 217 | }; 218 | DB357E8A228D37C30009B88B /* Release */ = { 219 | isa = XCBuildConfiguration; 220 | buildSettings = { 221 | ALWAYS_SEARCH_USER_PATHS = NO; 222 | CLANG_ANALYZER_NONNULL = YES; 223 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 224 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 225 | CLANG_CXX_LIBRARY = "libc++"; 226 | CLANG_ENABLE_MODULES = YES; 227 | CLANG_ENABLE_OBJC_ARC = YES; 228 | CLANG_ENABLE_OBJC_WEAK = YES; 229 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 230 | CLANG_WARN_BOOL_CONVERSION = YES; 231 | CLANG_WARN_COMMA = YES; 232 | CLANG_WARN_CONSTANT_CONVERSION = YES; 233 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 234 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 235 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 236 | CLANG_WARN_EMPTY_BODY = YES; 237 | CLANG_WARN_ENUM_CONVERSION = YES; 238 | CLANG_WARN_INFINITE_RECURSION = YES; 239 | CLANG_WARN_INT_CONVERSION = YES; 240 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 241 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 242 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 243 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 244 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 245 | CLANG_WARN_STRICT_PROTOTYPES = YES; 246 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 247 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 248 | CLANG_WARN_UNREACHABLE_CODE = YES; 249 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 250 | CODE_SIGN_IDENTITY = "iPhone Developer"; 251 | COPY_PHASE_STRIP = NO; 252 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 253 | ENABLE_NS_ASSERTIONS = NO; 254 | ENABLE_STRICT_OBJC_MSGSEND = YES; 255 | GCC_C_LANGUAGE_STANDARD = gnu11; 256 | GCC_NO_COMMON_BLOCKS = YES; 257 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 258 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 259 | GCC_WARN_UNDECLARED_SELECTOR = YES; 260 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 261 | GCC_WARN_UNUSED_FUNCTION = YES; 262 | GCC_WARN_UNUSED_VARIABLE = YES; 263 | IPHONEOS_DEPLOYMENT_TARGET = 12.2; 264 | MTL_ENABLE_DEBUG_INFO = NO; 265 | MTL_FAST_MATH = YES; 266 | SDKROOT = iphoneos; 267 | SWIFT_COMPILATION_MODE = wholemodule; 268 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 269 | VALIDATE_PRODUCT = YES; 270 | }; 271 | name = Release; 272 | }; 273 | DB357E8C228D37C30009B88B /* Debug */ = { 274 | isa = XCBuildConfiguration; 275 | buildSettings = { 276 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 277 | CODE_SIGN_STYLE = Automatic; 278 | DEVELOPMENT_TEAM = G5S3RZ43N7; 279 | INFOPLIST_FILE = Demo/Info.plist; 280 | LD_RUNPATH_SEARCH_PATHS = ( 281 | "$(inherited)", 282 | "@executable_path/Frameworks", 283 | ); 284 | PRODUCT_BUNDLE_IDENTIFIER = com.twolivesleft.Demo; 285 | PRODUCT_NAME = "$(TARGET_NAME)"; 286 | SWIFT_VERSION = 5.0; 287 | TARGETED_DEVICE_FAMILY = "1,2"; 288 | }; 289 | name = Debug; 290 | }; 291 | DB357E8D228D37C30009B88B /* Release */ = { 292 | isa = XCBuildConfiguration; 293 | buildSettings = { 294 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 295 | CODE_SIGN_STYLE = Automatic; 296 | DEVELOPMENT_TEAM = G5S3RZ43N7; 297 | INFOPLIST_FILE = Demo/Info.plist; 298 | LD_RUNPATH_SEARCH_PATHS = ( 299 | "$(inherited)", 300 | "@executable_path/Frameworks", 301 | ); 302 | PRODUCT_BUNDLE_IDENTIFIER = com.twolivesleft.Demo; 303 | PRODUCT_NAME = "$(TARGET_NAME)"; 304 | SWIFT_VERSION = 5.0; 305 | TARGETED_DEVICE_FAMILY = "1,2"; 306 | }; 307 | name = Release; 308 | }; 309 | /* End XCBuildConfiguration section */ 310 | 311 | /* Begin XCConfigurationList section */ 312 | DB357E74228D37C30009B88B /* Build configuration list for PBXProject "Demo" */ = { 313 | isa = XCConfigurationList; 314 | buildConfigurations = ( 315 | DB357E89228D37C30009B88B /* Debug */, 316 | DB357E8A228D37C30009B88B /* Release */, 317 | ); 318 | defaultConfigurationIsVisible = 0; 319 | defaultConfigurationName = Release; 320 | }; 321 | DB357E8B228D37C30009B88B /* Build configuration list for PBXNativeTarget "Demo" */ = { 322 | isa = XCConfigurationList; 323 | buildConfigurations = ( 324 | DB357E8C228D37C30009B88B /* Debug */, 325 | DB357E8D228D37C30009B88B /* Release */, 326 | ); 327 | defaultConfigurationIsVisible = 0; 328 | defaultConfigurationName = Release; 329 | }; 330 | /* End XCConfigurationList section */ 331 | }; 332 | rootObject = DB357E71228D37C30009B88B /* Project object */; 333 | } 334 | -------------------------------------------------------------------------------- /Demo/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // Demo 4 | // 5 | // Created by Simeon Saint-Saens on 16/5/19. 6 | // Copyright © 2019 Enabled. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 17 | 18 | window = UIWindow(frame: UIScreen.main.bounds) 19 | window?.rootViewController = ViewController() 20 | window?.makeKeyAndVisible() 21 | 22 | return true 23 | } 24 | 25 | } 26 | 27 | -------------------------------------------------------------------------------- /Demo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /Demo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Demo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Demo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIRequiredDeviceCapabilities 26 | 27 | armv7 28 | 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /Demo/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // Demo 4 | // 5 | // Created by Simeon Saint-Saens on 16/5/19. 6 | // Copyright © 2019 Enabled. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | let square = UIView() 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | 18 | view.backgroundColor = .white 19 | 20 | square.translatesAutoresizingMaskIntoConstraints = false 21 | 22 | square.bounds = CGRect(origin: .zero, size: CGSize(width: 100, height: 100)) 23 | square.layer.cornerRadius = 7.0 24 | square.backgroundColor = .red 25 | 26 | view.addSubview(square) 27 | } 28 | 29 | override func viewDidAppear(_ animated: Bool) { 30 | super.viewDidAppear(animated) 31 | 32 | animateSequence() 33 | } 34 | 35 | func animateSequence() { 36 | let offset = CGSize(width: 90, height: 120) 37 | let size = view.bounds.size 38 | 39 | square.center = CGPoint(x: offset.width, y: offset.height) 40 | 41 | SequenceAnimator.animate(1.0) { 42 | self.square.center = CGPoint(x: size.width - offset.width, y: offset.height) 43 | }.animate(0.3) { 44 | self.square.transform = CGAffineTransform(rotationAngle: .pi/2.0) 45 | }.done { 46 | print("First corner") 47 | }.animate(1.0) { 48 | self.square.center = CGPoint(x: size.width - offset.width, y: size.height - offset.height) 49 | }.animate(0.3) { 50 | self.square.transform = CGAffineTransform(rotationAngle: .pi) 51 | }.animate(0.3, delay: 0.5) { 52 | self.square.backgroundColor = .blue 53 | }.animate(1.0) { 54 | self.square.center = CGPoint(x: offset.width, y: size.height - offset.height) 55 | }.animate(0.3) { 56 | self.square.transform = CGAffineTransform(rotationAngle: .pi*1.5) 57 | }.animate(1.0) { 58 | self.square.center = CGPoint(x: offset.width, y: offset.height) 59 | }.animate(0.3) { 60 | self.square.transform = CGAffineTransform(rotationAngle: .pi*2.0) 61 | self.square.backgroundColor = .green 62 | }.done { 63 | print("Animation complete") 64 | } 65 | } 66 | 67 | //Same as above using nested UIView implicit animation syntax 68 | func animateSequenceUIView() { 69 | let offset = CGSize(width: 90, height: 120) 70 | let size = view.bounds.size 71 | 72 | square.center = CGPoint(x: offset.width, y: offset.height) 73 | 74 | UIView.animate(withDuration: 1.0, animations: { 75 | self.square.center = CGPoint(x: size.width - offset.width, y: offset.height) 76 | }) { _ in 77 | 78 | UIView.animate(withDuration: 0.3, animations: { 79 | self.square.transform = CGAffineTransform(rotationAngle: .pi/2.0) 80 | }) { _ in 81 | print("First corner") 82 | 83 | UIView.animate(withDuration: 1.0, animations: { 84 | self.square.center = CGPoint(x: size.width - offset.width, y: size.height - offset.height) 85 | }) { _ in 86 | 87 | UIView.animate(withDuration: 0.3, animations: { 88 | self.square.transform = CGAffineTransform(rotationAngle: .pi) 89 | }) { _ in 90 | 91 | UIView.animate(withDuration: 0.3, delay: 0.5, options: [], animations: { 92 | self.square.backgroundColor = .blue 93 | }) { _ in 94 | 95 | UIView.animate(withDuration: 1.0, animations: { 96 | self.square.center = CGPoint(x: offset.width, y: size.height - offset.height) 97 | }) { _ in 98 | 99 | UIView.animate(withDuration: 0.3, animations: { 100 | self.square.transform = CGAffineTransform(rotationAngle: .pi*1.5) 101 | }) { _ in 102 | 103 | UIView.animate(withDuration: 1.0, animations: { 104 | self.square.center = CGPoint(x: offset.width, y: offset.height) 105 | }) { _ in 106 | 107 | UIView.animate(withDuration: 0.3, animations: { 108 | self.square.transform = CGAffineTransform(rotationAngle: .pi*2.0) 109 | self.square.backgroundColor = .green 110 | }) { _ in 111 | print("Animation complete") 112 | } 113 | } 114 | } 115 | } 116 | } 117 | } 118 | } 119 | } 120 | } 121 | } 122 | 123 | } 124 | 125 | -------------------------------------------------------------------------------- /Images/SequenceAnimatorComparison.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enabledhq/SequenceAnimator/95af755242b60d27b84ab1fc6b5ef120acd77a8b/Images/SequenceAnimatorComparison.gif -------------------------------------------------------------------------------- /Images/SequenceDemo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enabledhq/SequenceAnimator/95af755242b60d27b84ab1fc6b5ef120acd77a8b/Images/SequenceDemo.gif -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Enabled Solutions 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SequenceAnimator 2 | 3 | A wrapper for UIView animation which makes it easy to write sequences of animations 4 | 5 | So instead of writing: 6 | 7 | ```swift 8 | UIView.animate(withDuration: 0.5, animations: { 9 | //Some animation 10 | }) { done in 11 | UIView.animate(withDuration: 0.5, animations: { 12 | //Do another animation after the first... 13 | }, completion: ...) 14 | } 15 | ``` 16 | You write: 17 | 18 | ```swift 19 | SequenceAnimator.animate(0.5) { 20 | //Some animation 21 | }.animate(0.5) { 22 | //Another animation after the first 23 | }.done { 24 | //We're done 25 | } 26 | ``` 27 | 28 | You can intersperse `done` blocks throughout the chained animations and also use delays 29 | 30 | Take a look the included demo app 31 | 32 | ![Demo](Images/SequenceDemo.gif) 33 | 34 | Which includes a comparison of implicit `UIView` animation syntax with `SequenceAnimator` 35 | 36 | ![Code Comparison](Images/SequenceAnimatorComparison.gif) 37 | 38 | # Installation 39 | 40 | Copy SequenceAnimator.swift to your project 41 | -------------------------------------------------------------------------------- /SequenceAnimator.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SequenceAnimator.swift 3 | // 4 | // Created by Simeon Saint-Saens on 14/5/19. 5 | // Copyright © 2019 Enabled. All rights reserved. 6 | // 7 | 8 | import UIKit 9 | 10 | class SequenceAnimator { 11 | 12 | private var next: SequenceAnimator? 13 | 14 | private var completion: (()->Void)? 15 | private let animation: ()->Void 16 | 17 | private let duration: TimeInterval 18 | private let delay: TimeInterval 19 | 20 | private init(duration: TimeInterval, delay: TimeInterval = 0.0, animation: @escaping ()->Void) { 21 | self.duration = duration 22 | self.delay = delay 23 | self.animation = animation 24 | self.next = nil 25 | } 26 | 27 | private func begin() { 28 | UIView.animate(withDuration: duration, delay: delay, options: [], animations: animation) { 29 | _ in 30 | 31 | self.completion?() 32 | self.next?.begin() 33 | } 34 | } 35 | 36 | @discardableResult 37 | func animate(_ duration: TimeInterval, delay: TimeInterval = 0.0, _ animation: @escaping ()->Void) -> SequenceAnimator { 38 | 39 | next = SequenceAnimator(duration: duration, delay: delay, animation: animation) 40 | 41 | return next! 42 | } 43 | 44 | @discardableResult 45 | func done(_ completion: @escaping ()->Void) -> SequenceAnimator { 46 | 47 | self.completion = completion 48 | 49 | return self 50 | } 51 | 52 | @discardableResult 53 | static func animate(_ duration: TimeInterval, delay: TimeInterval = 0.0, _ animation: @escaping ()->Void) -> SequenceAnimator { 54 | 55 | let animator = SequenceAnimator(duration: duration, delay: delay, animation: animation) 56 | 57 | animator.begin() 58 | 59 | return animator 60 | } 61 | } 62 | --------------------------------------------------------------------------------