├── .gitignore ├── README.md ├── TaskSwitcherDemo.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── TaskSwitcherDemo ├── AppDelegate.h ├── AppDelegate.m ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard ├── Images.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── InfiniteScrollView.h ├── InfiniteScrollView.m ├── Info.plist ├── TaskSwitcherViewController.h ├── TaskSwitcherViewController.m └── main.m └── TaskSwitcherDemoTests ├── Info.plist └── TaskSwitcherDemoTests.m /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.swp 3 | *~.nib 4 | 5 | build/ 6 | xcuserdata/ 7 | *.pbxuser 8 | *.perspective 9 | *.perspectivev3 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TaskSwitcherDemo 2 | iOS 9 task switcher animation demo 3 | -------------------------------------------------------------------------------- /TaskSwitcherDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | FAF48B9D1B75A8120086C0F5 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = FAF48B9C1B75A8120086C0F5 /* main.m */; }; 11 | FAF48BA01B75A8120086C0F5 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = FAF48B9F1B75A8120086C0F5 /* AppDelegate.m */; }; 12 | FAF48BA61B75A8120086C0F5 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FAF48BA41B75A8120086C0F5 /* Main.storyboard */; }; 13 | FAF48BA81B75A8120086C0F5 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FAF48BA71B75A8120086C0F5 /* Images.xcassets */; }; 14 | FAF48BAB1B75A8120086C0F5 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = FAF48BA91B75A8120086C0F5 /* LaunchScreen.xib */; }; 15 | FAF48BB71B75A8120086C0F5 /* TaskSwitcherDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = FAF48BB61B75A8120086C0F5 /* TaskSwitcherDemoTests.m */; }; 16 | FAF48BC21B75A8220086C0F5 /* InfiniteScrollView.m in Sources */ = {isa = PBXBuildFile; fileRef = FAF48BC11B75A8220086C0F5 /* InfiniteScrollView.m */; }; 17 | FAF48BC51B75A8320086C0F5 /* TaskSwitcherViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FAF48BC41B75A8320086C0F5 /* TaskSwitcherViewController.m */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXContainerItemProxy section */ 21 | FAF48BB11B75A8120086C0F5 /* PBXContainerItemProxy */ = { 22 | isa = PBXContainerItemProxy; 23 | containerPortal = FAF48B8F1B75A8120086C0F5 /* Project object */; 24 | proxyType = 1; 25 | remoteGlobalIDString = FAF48B961B75A8120086C0F5; 26 | remoteInfo = TaskSwitcherDemo; 27 | }; 28 | /* End PBXContainerItemProxy section */ 29 | 30 | /* Begin PBXFileReference section */ 31 | FAF48B971B75A8120086C0F5 /* TaskSwitcherDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TaskSwitcherDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 32 | FAF48B9B1B75A8120086C0F5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 33 | FAF48B9C1B75A8120086C0F5 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 34 | FAF48B9E1B75A8120086C0F5 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 35 | FAF48B9F1B75A8120086C0F5 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 36 | FAF48BA51B75A8120086C0F5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 37 | FAF48BA71B75A8120086C0F5 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 38 | FAF48BAA1B75A8120086C0F5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 39 | FAF48BB01B75A8120086C0F5 /* TaskSwitcherDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TaskSwitcherDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 40 | FAF48BB51B75A8120086C0F5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 41 | FAF48BB61B75A8120086C0F5 /* TaskSwitcherDemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TaskSwitcherDemoTests.m; sourceTree = ""; }; 42 | FAF48BC01B75A8220086C0F5 /* InfiniteScrollView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InfiniteScrollView.h; sourceTree = ""; }; 43 | FAF48BC11B75A8220086C0F5 /* InfiniteScrollView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InfiniteScrollView.m; sourceTree = ""; }; 44 | FAF48BC31B75A8320086C0F5 /* TaskSwitcherViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TaskSwitcherViewController.h; sourceTree = ""; }; 45 | FAF48BC41B75A8320086C0F5 /* TaskSwitcherViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TaskSwitcherViewController.m; sourceTree = ""; }; 46 | /* End PBXFileReference section */ 47 | 48 | /* Begin PBXFrameworksBuildPhase section */ 49 | FAF48B941B75A8120086C0F5 /* Frameworks */ = { 50 | isa = PBXFrameworksBuildPhase; 51 | buildActionMask = 2147483647; 52 | files = ( 53 | ); 54 | runOnlyForDeploymentPostprocessing = 0; 55 | }; 56 | FAF48BAD1B75A8120086C0F5 /* Frameworks */ = { 57 | isa = PBXFrameworksBuildPhase; 58 | buildActionMask = 2147483647; 59 | files = ( 60 | ); 61 | runOnlyForDeploymentPostprocessing = 0; 62 | }; 63 | /* End PBXFrameworksBuildPhase section */ 64 | 65 | /* Begin PBXGroup section */ 66 | FAF48B8E1B75A8120086C0F5 = { 67 | isa = PBXGroup; 68 | children = ( 69 | FAF48B991B75A8120086C0F5 /* TaskSwitcherDemo */, 70 | FAF48BB31B75A8120086C0F5 /* TaskSwitcherDemoTests */, 71 | FAF48B981B75A8120086C0F5 /* Products */, 72 | ); 73 | sourceTree = ""; 74 | }; 75 | FAF48B981B75A8120086C0F5 /* Products */ = { 76 | isa = PBXGroup; 77 | children = ( 78 | FAF48B971B75A8120086C0F5 /* TaskSwitcherDemo.app */, 79 | FAF48BB01B75A8120086C0F5 /* TaskSwitcherDemoTests.xctest */, 80 | ); 81 | name = Products; 82 | sourceTree = ""; 83 | }; 84 | FAF48B991B75A8120086C0F5 /* TaskSwitcherDemo */ = { 85 | isa = PBXGroup; 86 | children = ( 87 | FAF48BC31B75A8320086C0F5 /* TaskSwitcherViewController.h */, 88 | FAF48BC41B75A8320086C0F5 /* TaskSwitcherViewController.m */, 89 | FAF48BC01B75A8220086C0F5 /* InfiniteScrollView.h */, 90 | FAF48BC11B75A8220086C0F5 /* InfiniteScrollView.m */, 91 | FAF48B9E1B75A8120086C0F5 /* AppDelegate.h */, 92 | FAF48B9F1B75A8120086C0F5 /* AppDelegate.m */, 93 | FAF48BA41B75A8120086C0F5 /* Main.storyboard */, 94 | FAF48BA71B75A8120086C0F5 /* Images.xcassets */, 95 | FAF48BA91B75A8120086C0F5 /* LaunchScreen.xib */, 96 | FAF48B9A1B75A8120086C0F5 /* Supporting Files */, 97 | ); 98 | path = TaskSwitcherDemo; 99 | sourceTree = ""; 100 | }; 101 | FAF48B9A1B75A8120086C0F5 /* Supporting Files */ = { 102 | isa = PBXGroup; 103 | children = ( 104 | FAF48B9B1B75A8120086C0F5 /* Info.plist */, 105 | FAF48B9C1B75A8120086C0F5 /* main.m */, 106 | ); 107 | name = "Supporting Files"; 108 | sourceTree = ""; 109 | }; 110 | FAF48BB31B75A8120086C0F5 /* TaskSwitcherDemoTests */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | FAF48BB61B75A8120086C0F5 /* TaskSwitcherDemoTests.m */, 114 | FAF48BB41B75A8120086C0F5 /* Supporting Files */, 115 | ); 116 | path = TaskSwitcherDemoTests; 117 | sourceTree = ""; 118 | }; 119 | FAF48BB41B75A8120086C0F5 /* Supporting Files */ = { 120 | isa = PBXGroup; 121 | children = ( 122 | FAF48BB51B75A8120086C0F5 /* Info.plist */, 123 | ); 124 | name = "Supporting Files"; 125 | sourceTree = ""; 126 | }; 127 | /* End PBXGroup section */ 128 | 129 | /* Begin PBXNativeTarget section */ 130 | FAF48B961B75A8120086C0F5 /* TaskSwitcherDemo */ = { 131 | isa = PBXNativeTarget; 132 | buildConfigurationList = FAF48BBA1B75A8120086C0F5 /* Build configuration list for PBXNativeTarget "TaskSwitcherDemo" */; 133 | buildPhases = ( 134 | FAF48B931B75A8120086C0F5 /* Sources */, 135 | FAF48B941B75A8120086C0F5 /* Frameworks */, 136 | FAF48B951B75A8120086C0F5 /* Resources */, 137 | ); 138 | buildRules = ( 139 | ); 140 | dependencies = ( 141 | ); 142 | name = TaskSwitcherDemo; 143 | productName = TaskSwitcherDemo; 144 | productReference = FAF48B971B75A8120086C0F5 /* TaskSwitcherDemo.app */; 145 | productType = "com.apple.product-type.application"; 146 | }; 147 | FAF48BAF1B75A8120086C0F5 /* TaskSwitcherDemoTests */ = { 148 | isa = PBXNativeTarget; 149 | buildConfigurationList = FAF48BBD1B75A8120086C0F5 /* Build configuration list for PBXNativeTarget "TaskSwitcherDemoTests" */; 150 | buildPhases = ( 151 | FAF48BAC1B75A8120086C0F5 /* Sources */, 152 | FAF48BAD1B75A8120086C0F5 /* Frameworks */, 153 | FAF48BAE1B75A8120086C0F5 /* Resources */, 154 | ); 155 | buildRules = ( 156 | ); 157 | dependencies = ( 158 | FAF48BB21B75A8120086C0F5 /* PBXTargetDependency */, 159 | ); 160 | name = TaskSwitcherDemoTests; 161 | productName = TaskSwitcherDemoTests; 162 | productReference = FAF48BB01B75A8120086C0F5 /* TaskSwitcherDemoTests.xctest */; 163 | productType = "com.apple.product-type.bundle.unit-test"; 164 | }; 165 | /* End PBXNativeTarget section */ 166 | 167 | /* Begin PBXProject section */ 168 | FAF48B8F1B75A8120086C0F5 /* Project object */ = { 169 | isa = PBXProject; 170 | attributes = { 171 | LastUpgradeCheck = 0630; 172 | ORGANIZATIONNAME = glow; 173 | TargetAttributes = { 174 | FAF48B961B75A8120086C0F5 = { 175 | CreatedOnToolsVersion = 6.3; 176 | }; 177 | FAF48BAF1B75A8120086C0F5 = { 178 | CreatedOnToolsVersion = 6.3; 179 | TestTargetID = FAF48B961B75A8120086C0F5; 180 | }; 181 | }; 182 | }; 183 | buildConfigurationList = FAF48B921B75A8120086C0F5 /* Build configuration list for PBXProject "TaskSwitcherDemo" */; 184 | compatibilityVersion = "Xcode 3.2"; 185 | developmentRegion = English; 186 | hasScannedForEncodings = 0; 187 | knownRegions = ( 188 | en, 189 | Base, 190 | ); 191 | mainGroup = FAF48B8E1B75A8120086C0F5; 192 | productRefGroup = FAF48B981B75A8120086C0F5 /* Products */; 193 | projectDirPath = ""; 194 | projectRoot = ""; 195 | targets = ( 196 | FAF48B961B75A8120086C0F5 /* TaskSwitcherDemo */, 197 | FAF48BAF1B75A8120086C0F5 /* TaskSwitcherDemoTests */, 198 | ); 199 | }; 200 | /* End PBXProject section */ 201 | 202 | /* Begin PBXResourcesBuildPhase section */ 203 | FAF48B951B75A8120086C0F5 /* Resources */ = { 204 | isa = PBXResourcesBuildPhase; 205 | buildActionMask = 2147483647; 206 | files = ( 207 | FAF48BA61B75A8120086C0F5 /* Main.storyboard in Resources */, 208 | FAF48BAB1B75A8120086C0F5 /* LaunchScreen.xib in Resources */, 209 | FAF48BA81B75A8120086C0F5 /* Images.xcassets in Resources */, 210 | ); 211 | runOnlyForDeploymentPostprocessing = 0; 212 | }; 213 | FAF48BAE1B75A8120086C0F5 /* Resources */ = { 214 | isa = PBXResourcesBuildPhase; 215 | buildActionMask = 2147483647; 216 | files = ( 217 | ); 218 | runOnlyForDeploymentPostprocessing = 0; 219 | }; 220 | /* End PBXResourcesBuildPhase section */ 221 | 222 | /* Begin PBXSourcesBuildPhase section */ 223 | FAF48B931B75A8120086C0F5 /* Sources */ = { 224 | isa = PBXSourcesBuildPhase; 225 | buildActionMask = 2147483647; 226 | files = ( 227 | FAF48BC21B75A8220086C0F5 /* InfiniteScrollView.m in Sources */, 228 | FAF48BA01B75A8120086C0F5 /* AppDelegate.m in Sources */, 229 | FAF48BC51B75A8320086C0F5 /* TaskSwitcherViewController.m in Sources */, 230 | FAF48B9D1B75A8120086C0F5 /* main.m in Sources */, 231 | ); 232 | runOnlyForDeploymentPostprocessing = 0; 233 | }; 234 | FAF48BAC1B75A8120086C0F5 /* Sources */ = { 235 | isa = PBXSourcesBuildPhase; 236 | buildActionMask = 2147483647; 237 | files = ( 238 | FAF48BB71B75A8120086C0F5 /* TaskSwitcherDemoTests.m in Sources */, 239 | ); 240 | runOnlyForDeploymentPostprocessing = 0; 241 | }; 242 | /* End PBXSourcesBuildPhase section */ 243 | 244 | /* Begin PBXTargetDependency section */ 245 | FAF48BB21B75A8120086C0F5 /* PBXTargetDependency */ = { 246 | isa = PBXTargetDependency; 247 | target = FAF48B961B75A8120086C0F5 /* TaskSwitcherDemo */; 248 | targetProxy = FAF48BB11B75A8120086C0F5 /* PBXContainerItemProxy */; 249 | }; 250 | /* End PBXTargetDependency section */ 251 | 252 | /* Begin PBXVariantGroup section */ 253 | FAF48BA41B75A8120086C0F5 /* Main.storyboard */ = { 254 | isa = PBXVariantGroup; 255 | children = ( 256 | FAF48BA51B75A8120086C0F5 /* Base */, 257 | ); 258 | name = Main.storyboard; 259 | sourceTree = ""; 260 | }; 261 | FAF48BA91B75A8120086C0F5 /* LaunchScreen.xib */ = { 262 | isa = PBXVariantGroup; 263 | children = ( 264 | FAF48BAA1B75A8120086C0F5 /* Base */, 265 | ); 266 | name = LaunchScreen.xib; 267 | sourceTree = ""; 268 | }; 269 | /* End PBXVariantGroup section */ 270 | 271 | /* Begin XCBuildConfiguration section */ 272 | FAF48BB81B75A8120086C0F5 /* Debug */ = { 273 | isa = XCBuildConfiguration; 274 | buildSettings = { 275 | ALWAYS_SEARCH_USER_PATHS = NO; 276 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 277 | CLANG_CXX_LIBRARY = "libc++"; 278 | CLANG_ENABLE_MODULES = YES; 279 | CLANG_ENABLE_OBJC_ARC = YES; 280 | CLANG_WARN_BOOL_CONVERSION = YES; 281 | CLANG_WARN_CONSTANT_CONVERSION = YES; 282 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 283 | CLANG_WARN_EMPTY_BODY = YES; 284 | CLANG_WARN_ENUM_CONVERSION = YES; 285 | CLANG_WARN_INT_CONVERSION = YES; 286 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 287 | CLANG_WARN_UNREACHABLE_CODE = YES; 288 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 289 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 290 | COPY_PHASE_STRIP = NO; 291 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 292 | ENABLE_STRICT_OBJC_MSGSEND = YES; 293 | GCC_C_LANGUAGE_STANDARD = gnu99; 294 | GCC_DYNAMIC_NO_PIC = NO; 295 | GCC_NO_COMMON_BLOCKS = YES; 296 | GCC_OPTIMIZATION_LEVEL = 0; 297 | GCC_PREPROCESSOR_DEFINITIONS = ( 298 | "DEBUG=1", 299 | "$(inherited)", 300 | ); 301 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 302 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 303 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 304 | GCC_WARN_UNDECLARED_SELECTOR = YES; 305 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 306 | GCC_WARN_UNUSED_FUNCTION = YES; 307 | GCC_WARN_UNUSED_VARIABLE = YES; 308 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 309 | MTL_ENABLE_DEBUG_INFO = YES; 310 | ONLY_ACTIVE_ARCH = YES; 311 | SDKROOT = iphoneos; 312 | }; 313 | name = Debug; 314 | }; 315 | FAF48BB91B75A8120086C0F5 /* Release */ = { 316 | isa = XCBuildConfiguration; 317 | buildSettings = { 318 | ALWAYS_SEARCH_USER_PATHS = NO; 319 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 320 | CLANG_CXX_LIBRARY = "libc++"; 321 | CLANG_ENABLE_MODULES = YES; 322 | CLANG_ENABLE_OBJC_ARC = YES; 323 | CLANG_WARN_BOOL_CONVERSION = YES; 324 | CLANG_WARN_CONSTANT_CONVERSION = YES; 325 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 326 | CLANG_WARN_EMPTY_BODY = YES; 327 | CLANG_WARN_ENUM_CONVERSION = YES; 328 | CLANG_WARN_INT_CONVERSION = YES; 329 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 330 | CLANG_WARN_UNREACHABLE_CODE = YES; 331 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 332 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 333 | COPY_PHASE_STRIP = NO; 334 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 335 | ENABLE_NS_ASSERTIONS = NO; 336 | ENABLE_STRICT_OBJC_MSGSEND = YES; 337 | GCC_C_LANGUAGE_STANDARD = gnu99; 338 | GCC_NO_COMMON_BLOCKS = YES; 339 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 340 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 341 | GCC_WARN_UNDECLARED_SELECTOR = YES; 342 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 343 | GCC_WARN_UNUSED_FUNCTION = YES; 344 | GCC_WARN_UNUSED_VARIABLE = YES; 345 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 346 | MTL_ENABLE_DEBUG_INFO = NO; 347 | SDKROOT = iphoneos; 348 | VALIDATE_PRODUCT = YES; 349 | }; 350 | name = Release; 351 | }; 352 | FAF48BBB1B75A8120086C0F5 /* Debug */ = { 353 | isa = XCBuildConfiguration; 354 | buildSettings = { 355 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 356 | INFOPLIST_FILE = TaskSwitcherDemo/Info.plist; 357 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 358 | PRODUCT_NAME = "$(TARGET_NAME)"; 359 | }; 360 | name = Debug; 361 | }; 362 | FAF48BBC1B75A8120086C0F5 /* Release */ = { 363 | isa = XCBuildConfiguration; 364 | buildSettings = { 365 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 366 | INFOPLIST_FILE = TaskSwitcherDemo/Info.plist; 367 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 368 | PRODUCT_NAME = "$(TARGET_NAME)"; 369 | }; 370 | name = Release; 371 | }; 372 | FAF48BBE1B75A8120086C0F5 /* Debug */ = { 373 | isa = XCBuildConfiguration; 374 | buildSettings = { 375 | BUNDLE_LOADER = "$(TEST_HOST)"; 376 | FRAMEWORK_SEARCH_PATHS = ( 377 | "$(SDKROOT)/Developer/Library/Frameworks", 378 | "$(inherited)", 379 | ); 380 | GCC_PREPROCESSOR_DEFINITIONS = ( 381 | "DEBUG=1", 382 | "$(inherited)", 383 | ); 384 | INFOPLIST_FILE = TaskSwitcherDemoTests/Info.plist; 385 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 386 | PRODUCT_NAME = "$(TARGET_NAME)"; 387 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TaskSwitcherDemo.app/TaskSwitcherDemo"; 388 | }; 389 | name = Debug; 390 | }; 391 | FAF48BBF1B75A8120086C0F5 /* Release */ = { 392 | isa = XCBuildConfiguration; 393 | buildSettings = { 394 | BUNDLE_LOADER = "$(TEST_HOST)"; 395 | FRAMEWORK_SEARCH_PATHS = ( 396 | "$(SDKROOT)/Developer/Library/Frameworks", 397 | "$(inherited)", 398 | ); 399 | INFOPLIST_FILE = TaskSwitcherDemoTests/Info.plist; 400 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 401 | PRODUCT_NAME = "$(TARGET_NAME)"; 402 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TaskSwitcherDemo.app/TaskSwitcherDemo"; 403 | }; 404 | name = Release; 405 | }; 406 | /* End XCBuildConfiguration section */ 407 | 408 | /* Begin XCConfigurationList section */ 409 | FAF48B921B75A8120086C0F5 /* Build configuration list for PBXProject "TaskSwitcherDemo" */ = { 410 | isa = XCConfigurationList; 411 | buildConfigurations = ( 412 | FAF48BB81B75A8120086C0F5 /* Debug */, 413 | FAF48BB91B75A8120086C0F5 /* Release */, 414 | ); 415 | defaultConfigurationIsVisible = 0; 416 | defaultConfigurationName = Release; 417 | }; 418 | FAF48BBA1B75A8120086C0F5 /* Build configuration list for PBXNativeTarget "TaskSwitcherDemo" */ = { 419 | isa = XCConfigurationList; 420 | buildConfigurations = ( 421 | FAF48BBB1B75A8120086C0F5 /* Debug */, 422 | FAF48BBC1B75A8120086C0F5 /* Release */, 423 | ); 424 | defaultConfigurationIsVisible = 0; 425 | }; 426 | FAF48BBD1B75A8120086C0F5 /* Build configuration list for PBXNativeTarget "TaskSwitcherDemoTests" */ = { 427 | isa = XCConfigurationList; 428 | buildConfigurations = ( 429 | FAF48BBE1B75A8120086C0F5 /* Debug */, 430 | FAF48BBF1B75A8120086C0F5 /* Release */, 431 | ); 432 | defaultConfigurationIsVisible = 0; 433 | }; 434 | /* End XCConfigurationList section */ 435 | }; 436 | rootObject = FAF48B8F1B75A8120086C0F5 /* Project object */; 437 | } 438 | -------------------------------------------------------------------------------- /TaskSwitcherDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /TaskSwitcherDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // TaskSwitcherDemo 4 | // 5 | // Created by ltebean on 15/8/8. 6 | // Copyright (c) 2015年 glow. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /TaskSwitcherDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // TaskSwitcherDemo 4 | // 5 | // Created by ltebean on 15/8/8. 6 | // Copyright (c) 2015年 glow. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /TaskSwitcherDemo/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /TaskSwitcherDemo/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 | -------------------------------------------------------------------------------- /TaskSwitcherDemo/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 | } -------------------------------------------------------------------------------- /TaskSwitcherDemo/InfiniteScrollView.h: -------------------------------------------------------------------------------- 1 | // 2 | // LTInfiniteScrollView.h 3 | // LTInfiniteScrollView 4 | // 5 | // Created by ltebean on 14/11/21. 6 | // Copyright (c) 2014年 ltebean. All rights reserved. 7 | // 8 | 9 | #import 10 | typedef enum ScrollDirection { 11 | ScrollDirectionRight, 12 | ScrollDirectionLeft, 13 | } ScrollDirection; 14 | 15 | @protocol InfiniteScrollViewDelegate 16 | - (void)updateView:(UIView *)view withProgress:(CGFloat)progress scrollDirection:(ScrollDirection)direction; 17 | @end 18 | 19 | @protocol InfiniteScrollViewDataSource 20 | - (UIView *)viewAtIndex:(NSInteger)index reusingView:(UIView *)view; 21 | - (NSInteger)numberOfViews; 22 | - (NSInteger)numberOfVisibleViews; 23 | @end 24 | 25 | @interface InfiniteScrollView : UIView 26 | @property (nonatomic, readonly) NSInteger currentIndex; 27 | @property (nonatomic, weak) id dataSource; 28 | @property (nonatomic, weak) id delegate; 29 | @property (nonatomic) BOOL scrollEnabled; 30 | @property (nonatomic) BOOL pagingEnabled; 31 | @property (nonatomic) NSInteger maxScrollDistance; 32 | 33 | - (void)reloadData; 34 | - (void)scrollToIndex:(NSInteger)index animated:(BOOL)animated; 35 | - (UIView *)viewAtIndex:(NSInteger)index; 36 | - (NSArray *)allViews; 37 | @end 38 | -------------------------------------------------------------------------------- /TaskSwitcherDemo/InfiniteScrollView.m: -------------------------------------------------------------------------------- 1 | // 2 | // LTInfiniteScrollView.m 3 | // LTInfiniteScrollView 4 | // 5 | // Created by ltebean on 14/11/21. 6 | // Copyright (c) 2014年 ltebean. All rights reserved. 7 | // 8 | 9 | 10 | 11 | #import "InfiniteScrollView.h" 12 | 13 | @interface InfiniteScrollView() 14 | @property (nonatomic) CGSize viewSize; 15 | @property (nonatomic, strong) UIScrollView *scrollView; 16 | @property (nonatomic, strong) NSMutableArray *views; 17 | @property (nonatomic) NSInteger visibleViewCount; 18 | @property (nonatomic) NSInteger totalViewCount; 19 | @property (nonatomic) CGFloat preContentOffsetX; 20 | @property (nonatomic) CGFloat totalWidth; 21 | @property (nonatomic) BOOL dragging; 22 | @property (nonatomic) ScrollDirection scrollDirection; 23 | @end 24 | 25 | @implementation InfiniteScrollView 26 | 27 | - (instancetype)initWithFrame:(CGRect)frame 28 | { 29 | self = [super initWithFrame:frame]; 30 | if (self) { 31 | [self setup]; 32 | } 33 | return self; 34 | } 35 | 36 | - (instancetype)initWithCoder:(NSCoder *)aDecoder 37 | { 38 | self = [super initWithCoder:aDecoder]; 39 | if (self) { 40 | [self setup]; 41 | } 42 | return self; 43 | } 44 | 45 | - (void)setup 46 | { 47 | self.scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.bounds), CGRectGetHeight(self.bounds))]; 48 | self.scrollView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleHeight; 49 | self.scrollView.showsHorizontalScrollIndicator = NO; 50 | self.scrollView.delegate = self; 51 | self.scrollView.clipsToBounds = NO; 52 | self.scrollView.pagingEnabled = self.pagingEnabled; 53 | [self addSubview:self.scrollView]; 54 | } 55 | 56 | #pragma mark - public methods 57 | 58 | - (void)setPagingEnabled:(BOOL)pagingEnabled 59 | { 60 | _pagingEnabled = pagingEnabled; 61 | self.scrollView.pagingEnabled = pagingEnabled; 62 | } 63 | 64 | - (void)setScrollEnabled:(BOOL)scrollEnabled 65 | { 66 | _scrollEnabled = scrollEnabled; 67 | self.scrollView.scrollEnabled = scrollEnabled; 68 | } 69 | 70 | - (void)reloadData 71 | { 72 | 73 | for (UIView *view in self.views) { 74 | [view removeFromSuperview]; 75 | } 76 | 77 | self.visibleViewCount = [self.dataSource numberOfVisibleViews]; 78 | self.totalViewCount = [self.dataSource numberOfViews]; 79 | 80 | CGFloat viewWidth = CGRectGetWidth(self.bounds)/self.visibleViewCount; 81 | CGFloat viewHeight = CGRectGetHeight(self.bounds); 82 | self.viewSize = CGSizeMake(viewWidth, viewHeight); 83 | 84 | self.totalWidth = viewWidth * self.totalViewCount; 85 | 86 | self.scrollView.contentSize = CGSizeMake(self.totalWidth, CGRectGetHeight(self.bounds)); 87 | 88 | self.views = [NSMutableArray array]; 89 | 90 | int begin = -ceil(self.visibleViewCount / 2.0f); 91 | int end = ceil(self.visibleViewCount / 2.0f); 92 | _currentIndex = 0; 93 | 94 | self.scrollView.contentOffset = CGPointMake(self.totalWidth / 2-CGRectGetWidth(self.bounds) / 2, 0); 95 | 96 | CGFloat currentCenter = [self currentCenter].x; 97 | 98 | for (int i = begin; i<= end;i++) { 99 | UIView *view = [self.dataSource viewAtIndex:i reusingView:nil]; 100 | view.center = [self centerForViewAtIndex:i]; 101 | view.tag = i; 102 | [self.views addObject:view]; 103 | [self.scrollView addSubview:view]; 104 | CGFloat progress = (view.center.x - currentCenter) / CGRectGetWidth(self.bounds) * self.visibleViewCount; 105 | [self.delegate updateView:view withProgress:progress scrollDirection:self.scrollDirection]; 106 | } 107 | } 108 | 109 | - (void)scrollToIndex:(NSInteger)index animated:(BOOL)animated 110 | { 111 | self.dragging = YES; 112 | [self.scrollView setContentOffset:[self contentOffsetForIndex:index] animated:animated]; 113 | } 114 | 115 | - (UIView *)viewAtIndex:(NSInteger)index 116 | { 117 | CGPoint center = [self centerForViewAtIndex:index]; 118 | for (UIView *view in self.views) { 119 | if (fabs(center.x - view.center.x) <= self.viewSize.width / 2.0f) { 120 | return view; 121 | } 122 | } 123 | return nil; 124 | } 125 | 126 | - (NSArray *)allViews 127 | { 128 | return self.views; 129 | } 130 | 131 | # pragma mark - UIScrollView delegate 132 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView 133 | { 134 | CGFloat currentCenter = [self currentCenter].x; 135 | CGFloat offset = currentCenter - self.totalWidth / 2; 136 | _currentIndex = ceil((offset- self.viewSize.width / 2) / self.viewSize.width); 137 | 138 | for (UIView *view in self.views) { 139 | if ([self viewCanBeQueuedForReuse:view]) { 140 | NSInteger indexNeeded; 141 | NSInteger indexOfViewToReuse = (NSInteger)view.tag; 142 | if (indexOfViewToReuse < self.currentIndex) { 143 | indexNeeded = indexOfViewToReuse + self.visibleViewCount + 2; 144 | } else { 145 | indexNeeded = indexOfViewToReuse - (self.visibleViewCount + 2); 146 | } 147 | 148 | if (labs(indexNeeded) <= floorf(self.totalViewCount / 2)) { 149 | [view removeFromSuperview]; 150 | UIView *viewNeeded = [self.dataSource viewAtIndex:indexNeeded reusingView:view]; 151 | viewNeeded.center = [self centerForViewAtIndex:indexNeeded]; 152 | [self.scrollView addSubview:viewNeeded]; 153 | viewNeeded.tag = indexNeeded; 154 | } 155 | }; 156 | 157 | CGFloat progress = (view.center.x - currentCenter) / CGRectGetWidth(self.bounds) * self.visibleViewCount; 158 | [self.delegate updateView:view withProgress:progress scrollDirection:self.scrollDirection]; 159 | 160 | } 161 | if (self.scrollView.contentOffset.x > self.preContentOffsetX) { 162 | self.scrollDirection = ScrollDirectionLeft; 163 | } else { 164 | self.scrollDirection = ScrollDirectionRight; 165 | } 166 | self.preContentOffsetX = self.scrollView.contentOffset.x; 167 | } 168 | 169 | - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView 170 | { 171 | self.dragging = YES; 172 | } 173 | 174 | - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate 175 | { 176 | self.dragging = NO; 177 | if (!self.pagingEnabled && !decelerate) { 178 | [self.scrollView setContentOffset:[self contentOffsetForIndex:self.currentIndex] animated:YES]; 179 | } 180 | } 181 | 182 | - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView 183 | { 184 | if (!self.pagingEnabled) { 185 | [self.scrollView setContentOffset:[self contentOffsetForIndex:self.currentIndex] animated:YES]; 186 | } 187 | } 188 | 189 | - (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset 190 | { 191 | if (self.maxScrollDistance <= 0) { 192 | return; 193 | } 194 | CGFloat targetX = targetContentOffset -> x; 195 | CGFloat currentX = [self contentOffsetForIndex:self.currentIndex].x; 196 | if (fabs(targetX - currentX) <= self.viewSize.width / 2) { 197 | return; 198 | } else { 199 | NSInteger distance = self.maxScrollDistance - 1; 200 | NSInteger currentIndex = [self currentIndex]; 201 | NSInteger targetIndex = self.scrollDirection == ScrollDirectionLeft ? currentIndex + distance : currentIndex - distance; 202 | targetContentOffset -> x = [self contentOffsetForIndex:targetIndex].x; 203 | } 204 | } 205 | 206 | #pragma mark - helper methods 207 | 208 | - (CGPoint)currentCenter 209 | { 210 | CGFloat x = self.scrollView.contentOffset.x + CGRectGetWidth(self.bounds) / 2.0f; 211 | CGFloat y = self.scrollView.contentOffset.y; 212 | return CGPointMake(x, y); 213 | } 214 | 215 | - (CGPoint)contentOffsetForIndex:(NSInteger)index 216 | { 217 | CGFloat x = self.totalWidth / 2 + index*self.viewSize.width - CGRectGetWidth(self.bounds) / 2; 218 | return CGPointMake(x, 0); 219 | } 220 | 221 | - (CGPoint)centerForViewAtIndex:(NSInteger)index 222 | { 223 | CGFloat y = CGRectGetMidY(self.bounds); 224 | CGFloat x = self.totalWidth/2 + index * self.viewSize.width; 225 | return CGPointMake(x, y); 226 | } 227 | 228 | - (BOOL)viewCanBeQueuedForReuse:(UIView *)view 229 | { 230 | CGFloat distanceToCenter = [self currentCenter].x - view.center.x; 231 | CGFloat threshold = (ceil(self.visibleViewCount / 2.0f)) * self.viewSize.width + self.viewSize.width / 2.0f; 232 | if (self.scrollDirection == ScrollDirectionLeft) { 233 | if (distanceToCenter < 0){ 234 | return NO; 235 | } 236 | } else { 237 | if (distanceToCenter > 0) { 238 | return NO; 239 | } 240 | } 241 | if (fabs(distanceToCenter) > threshold) { 242 | return YES; 243 | } 244 | return NO; 245 | } 246 | @end 247 | -------------------------------------------------------------------------------- /TaskSwitcherDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.glow.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /TaskSwitcherDemo/TaskSwitcherViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TaskSwitcherViewController.h 3 | // LTInfiniteScrollView 4 | // 5 | // Created by ltebean on 15/8/7. 6 | // Copyright (c) 2015年 ltebean. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface TaskSwitcherViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /TaskSwitcherDemo/TaskSwitcherViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // TaskSwitcherViewController.m 3 | // LTInfiniteScrollView 4 | // 5 | // Created by ltebean on 15/8/7. 6 | // Copyright (c) 2015年 ltebean. All rights reserved. 7 | // 8 | 9 | #import "TaskSwitcherViewController.h" 10 | #import "InfiniteScrollView.h" 11 | 12 | #define SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width 13 | #define SCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height 14 | #define NUMBER_OF_VISIBLE_VIEWS 5 15 | #define COLOR [UIColor colorWithRed:0/255.0 green:175/255.0 blue:240/255.0 alpha:1] 16 | 17 | @interface TaskSwitcherViewController () 18 | @property (strong, nonatomic) InfiniteScrollView *scrollView; 19 | 20 | @end 21 | 22 | @implementation TaskSwitcherViewController 23 | 24 | - (void)viewDidLoad { 25 | [super viewDidLoad]; 26 | self.view.backgroundColor = COLOR; 27 | // Do any additional setup after loading the view. 28 | self.scrollView = [[InfiniteScrollView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)]; 29 | [self.view addSubview:self.scrollView]; 30 | 31 | self.scrollView.dataSource = self; 32 | self.scrollView.delegate = self; 33 | self.scrollView.maxScrollDistance = 3; 34 | } 35 | 36 | - (void)viewDidLayoutSubviews 37 | { 38 | [super viewDidLayoutSubviews]; 39 | [self.scrollView reloadData]; 40 | } 41 | 42 | # pragma mark - LTInfiniteScrollView dataSource 43 | - (NSInteger)numberOfViews 44 | { 45 | return 999; 46 | } 47 | 48 | - (NSInteger)numberOfVisibleViews 49 | { 50 | return NUMBER_OF_VISIBLE_VIEWS; 51 | } 52 | 53 | # pragma mark - LTInfiniteScrollView delegate 54 | - (UIView *)viewAtIndex:(NSInteger)index reusingView:(UIView *)view; 55 | { 56 | if (!view) { 57 | view = [self newCard]; 58 | } 59 | return view; 60 | } 61 | 62 | - (UIView *)newCard 63 | { 64 | CGFloat width = SCREEN_WIDTH / 10 * 7.2; 65 | UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, width, 500)]; 66 | 67 | UIView *icon = [[UIView alloc] initWithFrame:CGRectMake(20, 10, 40, 40)]; 68 | icon.backgroundColor = [UIColor whiteColor]; 69 | icon.layer.cornerRadius = 5; 70 | 71 | UIView *snapshot = [[UIView alloc] initWithFrame:CGRectMake(0, 60, width, 430)]; 72 | snapshot.backgroundColor = [UIColor whiteColor]; 73 | snapshot.layer.cornerRadius = 5; 74 | UIBezierPath *shadowPath = [UIBezierPath bezierPathWithRect:snapshot.bounds]; 75 | snapshot.layer.shadowColor = [UIColor blackColor].CGColor; 76 | snapshot.layer.shadowOffset = CGSizeMake(2.0f, 2.0f); 77 | snapshot.layer.shadowOpacity = .3; 78 | snapshot.layer.shadowPath = shadowPath.CGPath; 79 | 80 | [view addSubview:icon]; 81 | [view addSubview:snapshot]; 82 | return view; 83 | } 84 | 85 | - (void)updateView:(UIView *)view withProgress:(CGFloat)progress scrollDirection:(ScrollDirection)direction 86 | { 87 | 88 | // adjust z-index of each views 89 | NSMutableArray *views = [[self.scrollView allViews] mutableCopy]; 90 | [views sortUsingComparator:^NSComparisonResult(UIView *view1, UIView *view2) { 91 | return view1.tag > view2.tag; 92 | }]; 93 | for (UIView *view in views) { 94 | [view.superview bringSubviewToFront:view]; 95 | } 96 | 97 | // alpha 98 | if (progress >= 0) { 99 | view.alpha = 1; 100 | } else { 101 | view.alpha = 1 - fabs(progress) * 0.2; 102 | } 103 | 104 | 105 | CGAffineTransform transform = CGAffineTransformIdentity; 106 | 107 | // scale 108 | CGFloat scale = 1 + (progress) * 0.03; 109 | transform = CGAffineTransformScale(transform, scale, scale); 110 | 111 | // translation 112 | CGFloat translation = 0; 113 | if (progress > 0) { 114 | translation = fabs(progress) * SCREEN_WIDTH / 2.2; 115 | } else { 116 | translation = fabs(progress) * SCREEN_WIDTH / 15; 117 | } 118 | 119 | transform = CGAffineTransformTranslate(transform, translation, 0); 120 | view.transform = transform; 121 | } 122 | 123 | @end 124 | -------------------------------------------------------------------------------- /TaskSwitcherDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // TaskSwitcherDemo 4 | // 5 | // Created by ltebean on 15/8/8. 6 | // Copyright (c) 2015年 glow. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /TaskSwitcherDemoTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.glow.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /TaskSwitcherDemoTests/TaskSwitcherDemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // TaskSwitcherDemoTests.m 3 | // TaskSwitcherDemoTests 4 | // 5 | // Created by ltebean on 15/8/8. 6 | // Copyright (c) 2015年 glow. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface TaskSwitcherDemoTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation TaskSwitcherDemoTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | --------------------------------------------------------------------------------