├── Example.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── johndelong.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── johndelong.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── Example.xcscheme │ └── xcschememanagement.plist ├── Example ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── ML_logo_white.png └── ViewController.swift └── README.md /Example.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1566BB8B1CE374440075A567 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1566BB8A1CE374440075A567 /* AppDelegate.swift */; }; 11 | 1566BB8D1CE374440075A567 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1566BB8C1CE374440075A567 /* ViewController.swift */; }; 12 | 1566BB901CE374440075A567 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1566BB8E1CE374440075A567 /* Main.storyboard */; }; 13 | 1566BB921CE374440075A567 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1566BB911CE374440075A567 /* Assets.xcassets */; }; 14 | 1566BB951CE374440075A567 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1566BB931CE374440075A567 /* LaunchScreen.storyboard */; }; 15 | 1566BBA51CE3D8F10075A567 /* ML_logo_white.png in Resources */ = {isa = PBXBuildFile; fileRef = 1566BBA41CE3D8F10075A567 /* ML_logo_white.png */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXFileReference section */ 19 | 1566BB871CE374440075A567 /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; 20 | 1566BB8A1CE374440075A567 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 21 | 1566BB8C1CE374440075A567 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 22 | 1566BB8F1CE374440075A567 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 23 | 1566BB911CE374440075A567 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 24 | 1566BB941CE374440075A567 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 25 | 1566BB961CE374440075A567 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 26 | 1566BBA41CE3D8F10075A567 /* ML_logo_white.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ML_logo_white.png; sourceTree = ""; }; 27 | /* End PBXFileReference section */ 28 | 29 | /* Begin PBXFrameworksBuildPhase section */ 30 | 1566BB841CE374440075A567 /* Frameworks */ = { 31 | isa = PBXFrameworksBuildPhase; 32 | buildActionMask = 2147483647; 33 | files = ( 34 | ); 35 | runOnlyForDeploymentPostprocessing = 0; 36 | }; 37 | /* End PBXFrameworksBuildPhase section */ 38 | 39 | /* Begin PBXGroup section */ 40 | 1566BB7E1CE374440075A567 = { 41 | isa = PBXGroup; 42 | children = ( 43 | 1566BB891CE374440075A567 /* Example */, 44 | 1566BB881CE374440075A567 /* Products */, 45 | ); 46 | sourceTree = ""; 47 | }; 48 | 1566BB881CE374440075A567 /* Products */ = { 49 | isa = PBXGroup; 50 | children = ( 51 | 1566BB871CE374440075A567 /* Example.app */, 52 | ); 53 | name = Products; 54 | sourceTree = ""; 55 | }; 56 | 1566BB891CE374440075A567 /* Example */ = { 57 | isa = PBXGroup; 58 | children = ( 59 | 1566BB8A1CE374440075A567 /* AppDelegate.swift */, 60 | 1566BB8C1CE374440075A567 /* ViewController.swift */, 61 | 1566BB8E1CE374440075A567 /* Main.storyboard */, 62 | 1566BB911CE374440075A567 /* Assets.xcassets */, 63 | 1566BB931CE374440075A567 /* LaunchScreen.storyboard */, 64 | 1566BB961CE374440075A567 /* Info.plist */, 65 | 1566BBA41CE3D8F10075A567 /* ML_logo_white.png */, 66 | ); 67 | path = Example; 68 | sourceTree = ""; 69 | }; 70 | /* End PBXGroup section */ 71 | 72 | /* Begin PBXNativeTarget section */ 73 | 1566BB861CE374440075A567 /* Example */ = { 74 | isa = PBXNativeTarget; 75 | buildConfigurationList = 1566BB991CE374440075A567 /* Build configuration list for PBXNativeTarget "Example" */; 76 | buildPhases = ( 77 | 1566BB831CE374440075A567 /* Sources */, 78 | 1566BB841CE374440075A567 /* Frameworks */, 79 | 1566BB851CE374440075A567 /* Resources */, 80 | ); 81 | buildRules = ( 82 | ); 83 | dependencies = ( 84 | ); 85 | name = Example; 86 | productName = Example; 87 | productReference = 1566BB871CE374440075A567 /* Example.app */; 88 | productType = "com.apple.product-type.application"; 89 | }; 90 | /* End PBXNativeTarget section */ 91 | 92 | /* Begin PBXProject section */ 93 | 1566BB7F1CE374440075A567 /* Project object */ = { 94 | isa = PBXProject; 95 | attributes = { 96 | LastSwiftUpdateCheck = 0730; 97 | LastUpgradeCheck = 0730; 98 | ORGANIZATIONNAME = delong; 99 | TargetAttributes = { 100 | 1566BB861CE374440075A567 = { 101 | CreatedOnToolsVersion = 7.3; 102 | LastSwiftMigration = 0820; 103 | }; 104 | }; 105 | }; 106 | buildConfigurationList = 1566BB821CE374440075A567 /* Build configuration list for PBXProject "Example" */; 107 | compatibilityVersion = "Xcode 3.2"; 108 | developmentRegion = English; 109 | hasScannedForEncodings = 0; 110 | knownRegions = ( 111 | en, 112 | Base, 113 | ); 114 | mainGroup = 1566BB7E1CE374440075A567; 115 | productRefGroup = 1566BB881CE374440075A567 /* Products */; 116 | projectDirPath = ""; 117 | projectRoot = ""; 118 | targets = ( 119 | 1566BB861CE374440075A567 /* Example */, 120 | ); 121 | }; 122 | /* End PBXProject section */ 123 | 124 | /* Begin PBXResourcesBuildPhase section */ 125 | 1566BB851CE374440075A567 /* Resources */ = { 126 | isa = PBXResourcesBuildPhase; 127 | buildActionMask = 2147483647; 128 | files = ( 129 | 1566BB951CE374440075A567 /* LaunchScreen.storyboard in Resources */, 130 | 1566BBA51CE3D8F10075A567 /* ML_logo_white.png in Resources */, 131 | 1566BB921CE374440075A567 /* Assets.xcassets in Resources */, 132 | 1566BB901CE374440075A567 /* Main.storyboard in Resources */, 133 | ); 134 | runOnlyForDeploymentPostprocessing = 0; 135 | }; 136 | /* End PBXResourcesBuildPhase section */ 137 | 138 | /* Begin PBXSourcesBuildPhase section */ 139 | 1566BB831CE374440075A567 /* Sources */ = { 140 | isa = PBXSourcesBuildPhase; 141 | buildActionMask = 2147483647; 142 | files = ( 143 | 1566BB8D1CE374440075A567 /* ViewController.swift in Sources */, 144 | 1566BB8B1CE374440075A567 /* AppDelegate.swift in Sources */, 145 | ); 146 | runOnlyForDeploymentPostprocessing = 0; 147 | }; 148 | /* End PBXSourcesBuildPhase section */ 149 | 150 | /* Begin PBXVariantGroup section */ 151 | 1566BB8E1CE374440075A567 /* Main.storyboard */ = { 152 | isa = PBXVariantGroup; 153 | children = ( 154 | 1566BB8F1CE374440075A567 /* Base */, 155 | ); 156 | name = Main.storyboard; 157 | sourceTree = ""; 158 | }; 159 | 1566BB931CE374440075A567 /* LaunchScreen.storyboard */ = { 160 | isa = PBXVariantGroup; 161 | children = ( 162 | 1566BB941CE374440075A567 /* Base */, 163 | ); 164 | name = LaunchScreen.storyboard; 165 | sourceTree = ""; 166 | }; 167 | /* End PBXVariantGroup section */ 168 | 169 | /* Begin XCBuildConfiguration section */ 170 | 1566BB971CE374440075A567 /* Debug */ = { 171 | isa = XCBuildConfiguration; 172 | buildSettings = { 173 | ALWAYS_SEARCH_USER_PATHS = NO; 174 | CLANG_ANALYZER_NONNULL = YES; 175 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 176 | CLANG_CXX_LIBRARY = "libc++"; 177 | CLANG_ENABLE_MODULES = YES; 178 | CLANG_ENABLE_OBJC_ARC = YES; 179 | CLANG_WARN_BOOL_CONVERSION = YES; 180 | CLANG_WARN_CONSTANT_CONVERSION = YES; 181 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 182 | CLANG_WARN_EMPTY_BODY = YES; 183 | CLANG_WARN_ENUM_CONVERSION = YES; 184 | CLANG_WARN_INT_CONVERSION = YES; 185 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 186 | CLANG_WARN_UNREACHABLE_CODE = YES; 187 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 188 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 189 | COPY_PHASE_STRIP = NO; 190 | DEBUG_INFORMATION_FORMAT = dwarf; 191 | ENABLE_STRICT_OBJC_MSGSEND = YES; 192 | ENABLE_TESTABILITY = YES; 193 | GCC_C_LANGUAGE_STANDARD = gnu99; 194 | GCC_DYNAMIC_NO_PIC = NO; 195 | GCC_NO_COMMON_BLOCKS = YES; 196 | GCC_OPTIMIZATION_LEVEL = 0; 197 | GCC_PREPROCESSOR_DEFINITIONS = ( 198 | "DEBUG=1", 199 | "$(inherited)", 200 | ); 201 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 202 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 203 | GCC_WARN_UNDECLARED_SELECTOR = YES; 204 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 205 | GCC_WARN_UNUSED_FUNCTION = YES; 206 | GCC_WARN_UNUSED_VARIABLE = YES; 207 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 208 | MTL_ENABLE_DEBUG_INFO = YES; 209 | ONLY_ACTIVE_ARCH = YES; 210 | SDKROOT = iphoneos; 211 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 212 | TARGETED_DEVICE_FAMILY = "1,2"; 213 | }; 214 | name = Debug; 215 | }; 216 | 1566BB981CE374440075A567 /* Release */ = { 217 | isa = XCBuildConfiguration; 218 | buildSettings = { 219 | ALWAYS_SEARCH_USER_PATHS = NO; 220 | CLANG_ANALYZER_NONNULL = YES; 221 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 222 | CLANG_CXX_LIBRARY = "libc++"; 223 | CLANG_ENABLE_MODULES = YES; 224 | CLANG_ENABLE_OBJC_ARC = YES; 225 | CLANG_WARN_BOOL_CONVERSION = YES; 226 | CLANG_WARN_CONSTANT_CONVERSION = YES; 227 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 228 | CLANG_WARN_EMPTY_BODY = YES; 229 | CLANG_WARN_ENUM_CONVERSION = YES; 230 | CLANG_WARN_INT_CONVERSION = YES; 231 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 232 | CLANG_WARN_UNREACHABLE_CODE = YES; 233 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 234 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 235 | COPY_PHASE_STRIP = NO; 236 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 237 | ENABLE_NS_ASSERTIONS = NO; 238 | ENABLE_STRICT_OBJC_MSGSEND = YES; 239 | GCC_C_LANGUAGE_STANDARD = gnu99; 240 | GCC_NO_COMMON_BLOCKS = YES; 241 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 242 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 243 | GCC_WARN_UNDECLARED_SELECTOR = YES; 244 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 245 | GCC_WARN_UNUSED_FUNCTION = YES; 246 | GCC_WARN_UNUSED_VARIABLE = YES; 247 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 248 | MTL_ENABLE_DEBUG_INFO = NO; 249 | SDKROOT = iphoneos; 250 | TARGETED_DEVICE_FAMILY = "1,2"; 251 | VALIDATE_PRODUCT = YES; 252 | }; 253 | name = Release; 254 | }; 255 | 1566BB9A1CE374440075A567 /* Debug */ = { 256 | isa = XCBuildConfiguration; 257 | buildSettings = { 258 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 259 | INFOPLIST_FILE = Example/Info.plist; 260 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 261 | PRODUCT_BUNDLE_IDENTIFIER = com.Example; 262 | PRODUCT_NAME = "$(TARGET_NAME)"; 263 | SWIFT_VERSION = 3.0; 264 | }; 265 | name = Debug; 266 | }; 267 | 1566BB9B1CE374440075A567 /* Release */ = { 268 | isa = XCBuildConfiguration; 269 | buildSettings = { 270 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 271 | INFOPLIST_FILE = Example/Info.plist; 272 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 273 | PRODUCT_BUNDLE_IDENTIFIER = com.Example; 274 | PRODUCT_NAME = "$(TARGET_NAME)"; 275 | SWIFT_VERSION = 3.0; 276 | }; 277 | name = Release; 278 | }; 279 | /* End XCBuildConfiguration section */ 280 | 281 | /* Begin XCConfigurationList section */ 282 | 1566BB821CE374440075A567 /* Build configuration list for PBXProject "Example" */ = { 283 | isa = XCConfigurationList; 284 | buildConfigurations = ( 285 | 1566BB971CE374440075A567 /* Debug */, 286 | 1566BB981CE374440075A567 /* Release */, 287 | ); 288 | defaultConfigurationIsVisible = 0; 289 | defaultConfigurationName = Release; 290 | }; 291 | 1566BB991CE374440075A567 /* Build configuration list for PBXNativeTarget "Example" */ = { 292 | isa = XCConfigurationList; 293 | buildConfigurations = ( 294 | 1566BB9A1CE374440075A567 /* Debug */, 295 | 1566BB9B1CE374440075A567 /* Release */, 296 | ); 297 | defaultConfigurationIsVisible = 0; 298 | defaultConfigurationName = Release; 299 | }; 300 | /* End XCConfigurationList section */ 301 | }; 302 | rootObject = 1566BB7F1CE374440075A567 /* Project object */; 303 | } 304 | -------------------------------------------------------------------------------- /Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example.xcodeproj/project.xcworkspace/xcuserdata/johndelong.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MichiganLabs/AnimatingTableViewHeader/e01988aee5d0f56331c3738f8e8e8314e9e7bfcc/Example.xcodeproj/project.xcworkspace/xcuserdata/johndelong.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Example.xcodeproj/xcuserdata/johndelong.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /Example.xcodeproj/xcuserdata/johndelong.xcuserdatad/xcschemes/Example.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /Example.xcodeproj/xcuserdata/johndelong.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Example.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 1566BB861CE374440075A567 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Example/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // Example 4 | // 5 | // Created by John DeLong on 5/11/16. 6 | // Copyright © 2016 delong. 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/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /Example/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Example/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 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /Example/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /Example/ML_logo_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MichiganLabs/AnimatingTableViewHeader/e01988aee5d0f56331c3738f8e8e8314e9e7bfcc/Example/ML_logo_white.png -------------------------------------------------------------------------------- /Example/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // Example 4 | // 5 | // Created by John DeLong on 5/11/16. 6 | // Copyright © 2016 delong. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | @IBOutlet weak var tableView: UITableView! 14 | @IBOutlet weak var headerHeightConstraint: NSLayoutConstraint! 15 | 16 | let maxHeaderHeight: CGFloat = 88 17 | let minHeaderHeight: CGFloat = 44 18 | 19 | /// The last known scroll position 20 | var previousScrollOffset: CGFloat = 0 21 | 22 | /// The last known height of the scroll view content 23 | var previousScrollViewHeight: CGFloat = 0 24 | 25 | @IBOutlet weak var titleTopConstraint: NSLayoutConstraint! 26 | @IBOutlet weak var logoImageView: UIImageView! 27 | override func viewDidLoad() { 28 | super.viewDidLoad() 29 | // Do any additional setup after loading the view, typically from a nib. 30 | 31 | self.tableView.delegate = self 32 | self.tableView.dataSource = self 33 | 34 | // Start with an initial value for the content size 35 | self.previousScrollViewHeight = self.tableView.contentSize.height 36 | } 37 | 38 | override func viewWillAppear(_ animated: Bool) { 39 | super.viewWillAppear(animated) 40 | self.headerHeightConstraint.constant = self.maxHeaderHeight 41 | self.updateHeader() 42 | } 43 | } 44 | 45 | extension ViewController: UITableViewDataSource { 46 | func numberOfSections(in tableView: UITableView) -> Int { 47 | return 1 48 | } 49 | 50 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 51 | return 40 52 | } 53 | 54 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 55 | let cell = UITableViewCell() 56 | cell.textLabel!.text = "Cell \(indexPath.row)" 57 | return cell 58 | } 59 | } 60 | 61 | extension ViewController: UITableViewDelegate { 62 | func scrollViewDidScroll(_ scrollView: UIScrollView) { 63 | // Always update the previous values 64 | defer { 65 | self.previousScrollViewHeight = scrollView.contentSize.height 66 | self.previousScrollOffset = scrollView.contentOffset.y 67 | } 68 | 69 | let heightDiff = scrollView.contentSize.height - self.previousScrollViewHeight 70 | let scrollDiff = (scrollView.contentOffset.y - self.previousScrollOffset) 71 | 72 | // If the scroll was caused by the height of the scroll view changing, we want to do nothing. 73 | guard heightDiff == 0 else { return } 74 | 75 | let absoluteTop: CGFloat = 0; 76 | let absoluteBottom: CGFloat = scrollView.contentSize.height - scrollView.frame.size.height; 77 | 78 | let isScrollingDown = scrollDiff > 0 && scrollView.contentOffset.y > absoluteTop 79 | let isScrollingUp = scrollDiff < 0 && scrollView.contentOffset.y < absoluteBottom 80 | 81 | if canAnimateHeader(scrollView) { 82 | 83 | // Calculate new header height 84 | var newHeight = self.headerHeightConstraint.constant 85 | if isScrollingDown { 86 | newHeight = max(self.minHeaderHeight, self.headerHeightConstraint.constant - abs(scrollDiff)) 87 | } else if isScrollingUp { 88 | newHeight = min(self.maxHeaderHeight, self.headerHeightConstraint.constant + abs(scrollDiff)) 89 | } 90 | 91 | // Header needs to animate 92 | if newHeight != self.headerHeightConstraint.constant { 93 | self.headerHeightConstraint.constant = newHeight 94 | self.updateHeader() 95 | self.setScrollPosition(self.previousScrollOffset) 96 | } 97 | } 98 | } 99 | 100 | func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) { 101 | self.scrollViewDidStopScrolling() 102 | } 103 | 104 | func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) { 105 | if !decelerate { 106 | self.scrollViewDidStopScrolling() 107 | } 108 | } 109 | 110 | func scrollViewDidStopScrolling() { 111 | let range = self.maxHeaderHeight - self.minHeaderHeight 112 | let midPoint = self.minHeaderHeight + (range / 2) 113 | 114 | if self.headerHeightConstraint.constant > midPoint { 115 | self.expandHeader() 116 | } else { 117 | self.collapseHeader() 118 | } 119 | } 120 | 121 | func canAnimateHeader(_ scrollView: UIScrollView) -> Bool { 122 | // Calculate the size of the scrollView when header is collapsed 123 | let scrollViewMaxHeight = scrollView.frame.height + self.headerHeightConstraint.constant - minHeaderHeight 124 | 125 | // Make sure that when header is collapsed, there is still room to scroll 126 | return scrollView.contentSize.height > scrollViewMaxHeight 127 | } 128 | 129 | func collapseHeader() { 130 | self.view.layoutIfNeeded() 131 | UIView.animate(withDuration: 0.2, animations: { 132 | self.headerHeightConstraint.constant = self.minHeaderHeight 133 | self.updateHeader() 134 | self.view.layoutIfNeeded() 135 | }) 136 | } 137 | 138 | func expandHeader() { 139 | self.view.layoutIfNeeded() 140 | UIView.animate(withDuration: 0.2, animations: { 141 | self.headerHeightConstraint.constant = self.maxHeaderHeight 142 | self.updateHeader() 143 | self.view.layoutIfNeeded() 144 | }) 145 | } 146 | 147 | func setScrollPosition(_ position: CGFloat) { 148 | self.tableView.contentOffset = CGPoint(x: self.tableView.contentOffset.x, y: position) 149 | } 150 | 151 | func updateHeader() { 152 | let range = self.maxHeaderHeight - self.minHeaderHeight 153 | let openAmount = self.headerHeightConstraint.constant - self.minHeaderHeight 154 | let percentage = openAmount / range 155 | 156 | self.titleTopConstraint.constant = -openAmount + 10 157 | self.logoImageView.alpha = percentage 158 | } 159 | } 160 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AnimatingTableViewHeader 2 | A Swift project explaining how to animate a header above a UITableView 3 | 4 | Checkout my blog post [here](https://michiganlabs.com/2016/05/31/ios-animating-uitableview-header/) 5 | for details on how this project works! 6 | 7 | ![Animating Header](https://michiganlabs.com/uploads/blog/posts/demo.gif) 8 | 9 | ## Additional features not covered in the blog: 10 | * [Stretchy Header](https://github.com/MichiganLabs/AnimatingTableViewHeader/tree/feature/stretchy-header) 11 | --------------------------------------------------------------------------------