├── README.md ├── StretchHeader ├── StretchHeader.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── StretchHeader.xccheckout │ │ └── xcuserdata │ │ │ └── yumlive0909.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── yumlive0909.xcuserdatad │ │ └── xcschemes │ │ ├── StretchHeader.xcscheme │ │ └── xcschememanagement.plist ├── StretchHeader │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Base.lproj │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Info.plist │ ├── ViewController.h │ ├── ViewController.m │ ├── main.m │ ├── resources │ │ ├── avater@2x.png │ │ └── photo.jpg │ └── stretchTableHeader │ │ ├── HFStretchableTableHeaderView.h │ │ └── HFStretchableTableHeaderView.m ├── StretchHeaderTests │ ├── Info.plist │ └── StretchHeaderTests.m └── head.gif └── head.gif /README.md: -------------------------------------------------------------------------------- 1 | # StretchHeader 2 | this is a stretchable view in tableviewHeader,enlarge the view 3 | 4 | 这是一个可拉伸的view,主要放在UITableView的header处。 5 | 该功能是基于HFStretchableTableHeaderView作修改的,使得放在头部的view可以向下和向左右拉伸。 6 | 用于: 7 | 一些使用tableview的“个人界面”; 8 | 需要拉伸图片功能的tableview的头部; 9 | 使用: 10 | - (void)stretchHeaderForTableView:(UITableView*)tableView 11 | withView:(UIView*)view 12 | subViews:(UIView*)subview; 13 | 14 | 实现该方法--view:是放拉伸的背景图片,也可以自定义一个UIView。subview:放在view之上的,可自定义subView,也可直接实例一个透明的subview。 15 | 16 | *记得实现以下两个代理方法 17 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView 18 | - (void)viewDidLayoutSubviews 19 | 20 | 如果你觉得有更好的,可以试着再改一下哦~ 21 | 22 | ![](https://github.com/ljhang/StretchHeader/raw/master/head.gif) 23 | -------------------------------------------------------------------------------- /StretchHeader/StretchHeader.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 71F4FDB01B9FD037002277F2 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 71F4FDAF1B9FD037002277F2 /* main.m */; }; 11 | 71F4FDB31B9FD037002277F2 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 71F4FDB21B9FD037002277F2 /* AppDelegate.m */; }; 12 | 71F4FDB61B9FD037002277F2 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 71F4FDB51B9FD037002277F2 /* ViewController.m */; }; 13 | 71F4FDB91B9FD037002277F2 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 71F4FDB71B9FD037002277F2 /* Main.storyboard */; }; 14 | 71F4FDBB1B9FD037002277F2 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 71F4FDBA1B9FD037002277F2 /* Images.xcassets */; }; 15 | 71F4FDBE1B9FD037002277F2 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 71F4FDBC1B9FD037002277F2 /* LaunchScreen.xib */; }; 16 | 71F4FDCA1B9FD037002277F2 /* StretchHeaderTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 71F4FDC91B9FD037002277F2 /* StretchHeaderTests.m */; }; 17 | 71F4FDD71B9FD4B8002277F2 /* HFStretchableTableHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 71F4FDD61B9FD4B8002277F2 /* HFStretchableTableHeaderView.m */; }; 18 | 71F4FDDA1B9FD4BE002277F2 /* avater@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 71F4FDD81B9FD4BE002277F2 /* avater@2x.png */; }; 19 | 71F4FDDB1B9FD4BE002277F2 /* photo.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 71F4FDD91B9FD4BE002277F2 /* photo.jpg */; }; 20 | 71F4FDDD1B9FE71E002277F2 /* head.gif in Resources */ = {isa = PBXBuildFile; fileRef = 71F4FDDC1B9FE71E002277F2 /* head.gif */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXContainerItemProxy section */ 24 | 71F4FDC41B9FD037002277F2 /* PBXContainerItemProxy */ = { 25 | isa = PBXContainerItemProxy; 26 | containerPortal = 71F4FDA21B9FD037002277F2 /* Project object */; 27 | proxyType = 1; 28 | remoteGlobalIDString = 71F4FDA91B9FD037002277F2; 29 | remoteInfo = StretchHeader; 30 | }; 31 | /* End PBXContainerItemProxy section */ 32 | 33 | /* Begin PBXFileReference section */ 34 | 71F4FDAA1B9FD037002277F2 /* StretchHeader.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = StretchHeader.app; sourceTree = BUILT_PRODUCTS_DIR; }; 35 | 71F4FDAE1B9FD037002277F2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 36 | 71F4FDAF1B9FD037002277F2 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 37 | 71F4FDB11B9FD037002277F2 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 38 | 71F4FDB21B9FD037002277F2 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 39 | 71F4FDB41B9FD037002277F2 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 40 | 71F4FDB51B9FD037002277F2 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 41 | 71F4FDB81B9FD037002277F2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 42 | 71F4FDBA1B9FD037002277F2 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 43 | 71F4FDBD1B9FD037002277F2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 44 | 71F4FDC31B9FD037002277F2 /* StretchHeaderTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = StretchHeaderTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 45 | 71F4FDC81B9FD037002277F2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 46 | 71F4FDC91B9FD037002277F2 /* StretchHeaderTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = StretchHeaderTests.m; sourceTree = ""; }; 47 | 71F4FDD51B9FD4B8002277F2 /* HFStretchableTableHeaderView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HFStretchableTableHeaderView.h; sourceTree = ""; }; 48 | 71F4FDD61B9FD4B8002277F2 /* HFStretchableTableHeaderView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HFStretchableTableHeaderView.m; sourceTree = ""; }; 49 | 71F4FDD81B9FD4BE002277F2 /* avater@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "avater@2x.png"; sourceTree = ""; }; 50 | 71F4FDD91B9FD4BE002277F2 /* photo.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = photo.jpg; sourceTree = ""; }; 51 | 71F4FDDC1B9FE71E002277F2 /* head.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = head.gif; sourceTree = ""; }; 52 | /* End PBXFileReference section */ 53 | 54 | /* Begin PBXFrameworksBuildPhase section */ 55 | 71F4FDA71B9FD037002277F2 /* Frameworks */ = { 56 | isa = PBXFrameworksBuildPhase; 57 | buildActionMask = 2147483647; 58 | files = ( 59 | ); 60 | runOnlyForDeploymentPostprocessing = 0; 61 | }; 62 | 71F4FDC01B9FD037002277F2 /* Frameworks */ = { 63 | isa = PBXFrameworksBuildPhase; 64 | buildActionMask = 2147483647; 65 | files = ( 66 | ); 67 | runOnlyForDeploymentPostprocessing = 0; 68 | }; 69 | /* End PBXFrameworksBuildPhase section */ 70 | 71 | /* Begin PBXGroup section */ 72 | 71F4FDA11B9FD037002277F2 = { 73 | isa = PBXGroup; 74 | children = ( 75 | 71F4FDDC1B9FE71E002277F2 /* head.gif */, 76 | 71F4FDAC1B9FD037002277F2 /* StretchHeader */, 77 | 71F4FDC61B9FD037002277F2 /* StretchHeaderTests */, 78 | 71F4FDAB1B9FD037002277F2 /* Products */, 79 | ); 80 | sourceTree = ""; 81 | }; 82 | 71F4FDAB1B9FD037002277F2 /* Products */ = { 83 | isa = PBXGroup; 84 | children = ( 85 | 71F4FDAA1B9FD037002277F2 /* StretchHeader.app */, 86 | 71F4FDC31B9FD037002277F2 /* StretchHeaderTests.xctest */, 87 | ); 88 | name = Products; 89 | sourceTree = ""; 90 | }; 91 | 71F4FDAC1B9FD037002277F2 /* StretchHeader */ = { 92 | isa = PBXGroup; 93 | children = ( 94 | 71F4FDD31B9FD370002277F2 /* resources */, 95 | 71F4FDD41B9FD370002277F2 /* stretchTableHeader */, 96 | 71F4FDB11B9FD037002277F2 /* AppDelegate.h */, 97 | 71F4FDB21B9FD037002277F2 /* AppDelegate.m */, 98 | 71F4FDB41B9FD037002277F2 /* ViewController.h */, 99 | 71F4FDB51B9FD037002277F2 /* ViewController.m */, 100 | 71F4FDB71B9FD037002277F2 /* Main.storyboard */, 101 | 71F4FDBA1B9FD037002277F2 /* Images.xcassets */, 102 | 71F4FDBC1B9FD037002277F2 /* LaunchScreen.xib */, 103 | 71F4FDAD1B9FD037002277F2 /* Supporting Files */, 104 | ); 105 | path = StretchHeader; 106 | sourceTree = ""; 107 | }; 108 | 71F4FDAD1B9FD037002277F2 /* Supporting Files */ = { 109 | isa = PBXGroup; 110 | children = ( 111 | 71F4FDAE1B9FD037002277F2 /* Info.plist */, 112 | 71F4FDAF1B9FD037002277F2 /* main.m */, 113 | ); 114 | name = "Supporting Files"; 115 | sourceTree = ""; 116 | }; 117 | 71F4FDC61B9FD037002277F2 /* StretchHeaderTests */ = { 118 | isa = PBXGroup; 119 | children = ( 120 | 71F4FDC91B9FD037002277F2 /* StretchHeaderTests.m */, 121 | 71F4FDC71B9FD037002277F2 /* Supporting Files */, 122 | ); 123 | path = StretchHeaderTests; 124 | sourceTree = ""; 125 | }; 126 | 71F4FDC71B9FD037002277F2 /* Supporting Files */ = { 127 | isa = PBXGroup; 128 | children = ( 129 | 71F4FDC81B9FD037002277F2 /* Info.plist */, 130 | ); 131 | name = "Supporting Files"; 132 | sourceTree = ""; 133 | }; 134 | 71F4FDD31B9FD370002277F2 /* resources */ = { 135 | isa = PBXGroup; 136 | children = ( 137 | 71F4FDD81B9FD4BE002277F2 /* avater@2x.png */, 138 | 71F4FDD91B9FD4BE002277F2 /* photo.jpg */, 139 | ); 140 | path = resources; 141 | sourceTree = ""; 142 | }; 143 | 71F4FDD41B9FD370002277F2 /* stretchTableHeader */ = { 144 | isa = PBXGroup; 145 | children = ( 146 | 71F4FDD51B9FD4B8002277F2 /* HFStretchableTableHeaderView.h */, 147 | 71F4FDD61B9FD4B8002277F2 /* HFStretchableTableHeaderView.m */, 148 | ); 149 | path = stretchTableHeader; 150 | sourceTree = ""; 151 | }; 152 | /* End PBXGroup section */ 153 | 154 | /* Begin PBXNativeTarget section */ 155 | 71F4FDA91B9FD037002277F2 /* StretchHeader */ = { 156 | isa = PBXNativeTarget; 157 | buildConfigurationList = 71F4FDCD1B9FD037002277F2 /* Build configuration list for PBXNativeTarget "StretchHeader" */; 158 | buildPhases = ( 159 | 71F4FDA61B9FD037002277F2 /* Sources */, 160 | 71F4FDA71B9FD037002277F2 /* Frameworks */, 161 | 71F4FDA81B9FD037002277F2 /* Resources */, 162 | ); 163 | buildRules = ( 164 | ); 165 | dependencies = ( 166 | ); 167 | name = StretchHeader; 168 | productName = StretchHeader; 169 | productReference = 71F4FDAA1B9FD037002277F2 /* StretchHeader.app */; 170 | productType = "com.apple.product-type.application"; 171 | }; 172 | 71F4FDC21B9FD037002277F2 /* StretchHeaderTests */ = { 173 | isa = PBXNativeTarget; 174 | buildConfigurationList = 71F4FDD01B9FD037002277F2 /* Build configuration list for PBXNativeTarget "StretchHeaderTests" */; 175 | buildPhases = ( 176 | 71F4FDBF1B9FD037002277F2 /* Sources */, 177 | 71F4FDC01B9FD037002277F2 /* Frameworks */, 178 | 71F4FDC11B9FD037002277F2 /* Resources */, 179 | ); 180 | buildRules = ( 181 | ); 182 | dependencies = ( 183 | 71F4FDC51B9FD037002277F2 /* PBXTargetDependency */, 184 | ); 185 | name = StretchHeaderTests; 186 | productName = StretchHeaderTests; 187 | productReference = 71F4FDC31B9FD037002277F2 /* StretchHeaderTests.xctest */; 188 | productType = "com.apple.product-type.bundle.unit-test"; 189 | }; 190 | /* End PBXNativeTarget section */ 191 | 192 | /* Begin PBXProject section */ 193 | 71F4FDA21B9FD037002277F2 /* Project object */ = { 194 | isa = PBXProject; 195 | attributes = { 196 | LastUpgradeCheck = 0630; 197 | ORGANIZATIONNAME = yumlive0909; 198 | TargetAttributes = { 199 | 71F4FDA91B9FD037002277F2 = { 200 | CreatedOnToolsVersion = 6.3; 201 | }; 202 | 71F4FDC21B9FD037002277F2 = { 203 | CreatedOnToolsVersion = 6.3; 204 | TestTargetID = 71F4FDA91B9FD037002277F2; 205 | }; 206 | }; 207 | }; 208 | buildConfigurationList = 71F4FDA51B9FD037002277F2 /* Build configuration list for PBXProject "StretchHeader" */; 209 | compatibilityVersion = "Xcode 3.2"; 210 | developmentRegion = English; 211 | hasScannedForEncodings = 0; 212 | knownRegions = ( 213 | en, 214 | Base, 215 | ); 216 | mainGroup = 71F4FDA11B9FD037002277F2; 217 | productRefGroup = 71F4FDAB1B9FD037002277F2 /* Products */; 218 | projectDirPath = ""; 219 | projectRoot = ""; 220 | targets = ( 221 | 71F4FDA91B9FD037002277F2 /* StretchHeader */, 222 | 71F4FDC21B9FD037002277F2 /* StretchHeaderTests */, 223 | ); 224 | }; 225 | /* End PBXProject section */ 226 | 227 | /* Begin PBXResourcesBuildPhase section */ 228 | 71F4FDA81B9FD037002277F2 /* Resources */ = { 229 | isa = PBXResourcesBuildPhase; 230 | buildActionMask = 2147483647; 231 | files = ( 232 | 71F4FDB91B9FD037002277F2 /* Main.storyboard in Resources */, 233 | 71F4FDDA1B9FD4BE002277F2 /* avater@2x.png in Resources */, 234 | 71F4FDDB1B9FD4BE002277F2 /* photo.jpg in Resources */, 235 | 71F4FDBE1B9FD037002277F2 /* LaunchScreen.xib in Resources */, 236 | 71F4FDDD1B9FE71E002277F2 /* head.gif in Resources */, 237 | 71F4FDBB1B9FD037002277F2 /* Images.xcassets in Resources */, 238 | ); 239 | runOnlyForDeploymentPostprocessing = 0; 240 | }; 241 | 71F4FDC11B9FD037002277F2 /* Resources */ = { 242 | isa = PBXResourcesBuildPhase; 243 | buildActionMask = 2147483647; 244 | files = ( 245 | ); 246 | runOnlyForDeploymentPostprocessing = 0; 247 | }; 248 | /* End PBXResourcesBuildPhase section */ 249 | 250 | /* Begin PBXSourcesBuildPhase section */ 251 | 71F4FDA61B9FD037002277F2 /* Sources */ = { 252 | isa = PBXSourcesBuildPhase; 253 | buildActionMask = 2147483647; 254 | files = ( 255 | 71F4FDD71B9FD4B8002277F2 /* HFStretchableTableHeaderView.m in Sources */, 256 | 71F4FDB61B9FD037002277F2 /* ViewController.m in Sources */, 257 | 71F4FDB31B9FD037002277F2 /* AppDelegate.m in Sources */, 258 | 71F4FDB01B9FD037002277F2 /* main.m in Sources */, 259 | ); 260 | runOnlyForDeploymentPostprocessing = 0; 261 | }; 262 | 71F4FDBF1B9FD037002277F2 /* Sources */ = { 263 | isa = PBXSourcesBuildPhase; 264 | buildActionMask = 2147483647; 265 | files = ( 266 | 71F4FDCA1B9FD037002277F2 /* StretchHeaderTests.m in Sources */, 267 | ); 268 | runOnlyForDeploymentPostprocessing = 0; 269 | }; 270 | /* End PBXSourcesBuildPhase section */ 271 | 272 | /* Begin PBXTargetDependency section */ 273 | 71F4FDC51B9FD037002277F2 /* PBXTargetDependency */ = { 274 | isa = PBXTargetDependency; 275 | target = 71F4FDA91B9FD037002277F2 /* StretchHeader */; 276 | targetProxy = 71F4FDC41B9FD037002277F2 /* PBXContainerItemProxy */; 277 | }; 278 | /* End PBXTargetDependency section */ 279 | 280 | /* Begin PBXVariantGroup section */ 281 | 71F4FDB71B9FD037002277F2 /* Main.storyboard */ = { 282 | isa = PBXVariantGroup; 283 | children = ( 284 | 71F4FDB81B9FD037002277F2 /* Base */, 285 | ); 286 | name = Main.storyboard; 287 | sourceTree = ""; 288 | }; 289 | 71F4FDBC1B9FD037002277F2 /* LaunchScreen.xib */ = { 290 | isa = PBXVariantGroup; 291 | children = ( 292 | 71F4FDBD1B9FD037002277F2 /* Base */, 293 | ); 294 | name = LaunchScreen.xib; 295 | sourceTree = ""; 296 | }; 297 | /* End PBXVariantGroup section */ 298 | 299 | /* Begin XCBuildConfiguration section */ 300 | 71F4FDCB1B9FD037002277F2 /* Debug */ = { 301 | isa = XCBuildConfiguration; 302 | buildSettings = { 303 | ALWAYS_SEARCH_USER_PATHS = NO; 304 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 305 | CLANG_CXX_LIBRARY = "libc++"; 306 | CLANG_ENABLE_MODULES = YES; 307 | CLANG_ENABLE_OBJC_ARC = YES; 308 | CLANG_WARN_BOOL_CONVERSION = YES; 309 | CLANG_WARN_CONSTANT_CONVERSION = YES; 310 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 311 | CLANG_WARN_EMPTY_BODY = YES; 312 | CLANG_WARN_ENUM_CONVERSION = YES; 313 | CLANG_WARN_INT_CONVERSION = YES; 314 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 315 | CLANG_WARN_UNREACHABLE_CODE = YES; 316 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 317 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 318 | COPY_PHASE_STRIP = NO; 319 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 320 | ENABLE_STRICT_OBJC_MSGSEND = YES; 321 | GCC_C_LANGUAGE_STANDARD = gnu99; 322 | GCC_DYNAMIC_NO_PIC = NO; 323 | GCC_NO_COMMON_BLOCKS = YES; 324 | GCC_OPTIMIZATION_LEVEL = 0; 325 | GCC_PREPROCESSOR_DEFINITIONS = ( 326 | "DEBUG=1", 327 | "$(inherited)", 328 | ); 329 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 330 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 331 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 332 | GCC_WARN_UNDECLARED_SELECTOR = YES; 333 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 334 | GCC_WARN_UNUSED_FUNCTION = YES; 335 | GCC_WARN_UNUSED_VARIABLE = YES; 336 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 337 | MTL_ENABLE_DEBUG_INFO = YES; 338 | ONLY_ACTIVE_ARCH = YES; 339 | SDKROOT = iphoneos; 340 | }; 341 | name = Debug; 342 | }; 343 | 71F4FDCC1B9FD037002277F2 /* Release */ = { 344 | isa = XCBuildConfiguration; 345 | buildSettings = { 346 | ALWAYS_SEARCH_USER_PATHS = NO; 347 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 348 | CLANG_CXX_LIBRARY = "libc++"; 349 | CLANG_ENABLE_MODULES = YES; 350 | CLANG_ENABLE_OBJC_ARC = YES; 351 | CLANG_WARN_BOOL_CONVERSION = YES; 352 | CLANG_WARN_CONSTANT_CONVERSION = YES; 353 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 354 | CLANG_WARN_EMPTY_BODY = YES; 355 | CLANG_WARN_ENUM_CONVERSION = YES; 356 | CLANG_WARN_INT_CONVERSION = YES; 357 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 358 | CLANG_WARN_UNREACHABLE_CODE = YES; 359 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 360 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 361 | COPY_PHASE_STRIP = NO; 362 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 363 | ENABLE_NS_ASSERTIONS = NO; 364 | ENABLE_STRICT_OBJC_MSGSEND = YES; 365 | GCC_C_LANGUAGE_STANDARD = gnu99; 366 | GCC_NO_COMMON_BLOCKS = YES; 367 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 368 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 369 | GCC_WARN_UNDECLARED_SELECTOR = YES; 370 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 371 | GCC_WARN_UNUSED_FUNCTION = YES; 372 | GCC_WARN_UNUSED_VARIABLE = YES; 373 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 374 | MTL_ENABLE_DEBUG_INFO = NO; 375 | SDKROOT = iphoneos; 376 | VALIDATE_PRODUCT = YES; 377 | }; 378 | name = Release; 379 | }; 380 | 71F4FDCE1B9FD037002277F2 /* Debug */ = { 381 | isa = XCBuildConfiguration; 382 | buildSettings = { 383 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 384 | INFOPLIST_FILE = StretchHeader/Info.plist; 385 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 386 | PRODUCT_NAME = "$(TARGET_NAME)"; 387 | }; 388 | name = Debug; 389 | }; 390 | 71F4FDCF1B9FD037002277F2 /* Release */ = { 391 | isa = XCBuildConfiguration; 392 | buildSettings = { 393 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 394 | INFOPLIST_FILE = StretchHeader/Info.plist; 395 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 396 | PRODUCT_NAME = "$(TARGET_NAME)"; 397 | }; 398 | name = Release; 399 | }; 400 | 71F4FDD11B9FD037002277F2 /* Debug */ = { 401 | isa = XCBuildConfiguration; 402 | buildSettings = { 403 | BUNDLE_LOADER = "$(TEST_HOST)"; 404 | FRAMEWORK_SEARCH_PATHS = ( 405 | "$(SDKROOT)/Developer/Library/Frameworks", 406 | "$(inherited)", 407 | ); 408 | GCC_PREPROCESSOR_DEFINITIONS = ( 409 | "DEBUG=1", 410 | "$(inherited)", 411 | ); 412 | INFOPLIST_FILE = StretchHeaderTests/Info.plist; 413 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 414 | PRODUCT_NAME = "$(TARGET_NAME)"; 415 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/StretchHeader.app/StretchHeader"; 416 | }; 417 | name = Debug; 418 | }; 419 | 71F4FDD21B9FD037002277F2 /* Release */ = { 420 | isa = XCBuildConfiguration; 421 | buildSettings = { 422 | BUNDLE_LOADER = "$(TEST_HOST)"; 423 | FRAMEWORK_SEARCH_PATHS = ( 424 | "$(SDKROOT)/Developer/Library/Frameworks", 425 | "$(inherited)", 426 | ); 427 | INFOPLIST_FILE = StretchHeaderTests/Info.plist; 428 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 429 | PRODUCT_NAME = "$(TARGET_NAME)"; 430 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/StretchHeader.app/StretchHeader"; 431 | }; 432 | name = Release; 433 | }; 434 | /* End XCBuildConfiguration section */ 435 | 436 | /* Begin XCConfigurationList section */ 437 | 71F4FDA51B9FD037002277F2 /* Build configuration list for PBXProject "StretchHeader" */ = { 438 | isa = XCConfigurationList; 439 | buildConfigurations = ( 440 | 71F4FDCB1B9FD037002277F2 /* Debug */, 441 | 71F4FDCC1B9FD037002277F2 /* Release */, 442 | ); 443 | defaultConfigurationIsVisible = 0; 444 | defaultConfigurationName = Release; 445 | }; 446 | 71F4FDCD1B9FD037002277F2 /* Build configuration list for PBXNativeTarget "StretchHeader" */ = { 447 | isa = XCConfigurationList; 448 | buildConfigurations = ( 449 | 71F4FDCE1B9FD037002277F2 /* Debug */, 450 | 71F4FDCF1B9FD037002277F2 /* Release */, 451 | ); 452 | defaultConfigurationIsVisible = 0; 453 | defaultConfigurationName = Release; 454 | }; 455 | 71F4FDD01B9FD037002277F2 /* Build configuration list for PBXNativeTarget "StretchHeaderTests" */ = { 456 | isa = XCConfigurationList; 457 | buildConfigurations = ( 458 | 71F4FDD11B9FD037002277F2 /* Debug */, 459 | 71F4FDD21B9FD037002277F2 /* Release */, 460 | ); 461 | defaultConfigurationIsVisible = 0; 462 | defaultConfigurationName = Release; 463 | }; 464 | /* End XCConfigurationList section */ 465 | }; 466 | rootObject = 71F4FDA21B9FD037002277F2 /* Project object */; 467 | } 468 | -------------------------------------------------------------------------------- /StretchHeader/StretchHeader.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /StretchHeader/StretchHeader.xcodeproj/project.xcworkspace/xcshareddata/StretchHeader.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | 7E4744F8-0DE4-4884-8020-55FDD387B73C 9 | IDESourceControlProjectName 10 | StretchHeader 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | D1372BA784C930F1C292105DBB44512C0FB8B144 14 | https://github.com/ljhang/StretchHeader.git 15 | 16 | IDESourceControlProjectPath 17 | StretchHeader/StretchHeader.xcodeproj 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | D1372BA784C930F1C292105DBB44512C0FB8B144 21 | ../../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/ljhang/StretchHeader.git 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | D1372BA784C930F1C292105DBB44512C0FB8B144 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | D1372BA784C930F1C292105DBB44512C0FB8B144 36 | IDESourceControlWCCName 37 | StretchHeader 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /StretchHeader/StretchHeader.xcodeproj/project.xcworkspace/xcuserdata/yumlive0909.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljhang/StretchHeader/15beafa4788c41d92fe132fa11138d3ed2216178/StretchHeader/StretchHeader.xcodeproj/project.xcworkspace/xcuserdata/yumlive0909.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /StretchHeader/StretchHeader.xcodeproj/xcuserdata/yumlive0909.xcuserdatad/xcschemes/StretchHeader.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 75 | 77 | 83 | 84 | 85 | 86 | 87 | 88 | 94 | 96 | 102 | 103 | 104 | 105 | 107 | 108 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /StretchHeader/StretchHeader.xcodeproj/xcuserdata/yumlive0909.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | StretchHeader.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 71F4FDA91B9FD037002277F2 16 | 17 | primary 18 | 19 | 20 | 71F4FDC21B9FD037002277F2 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /StretchHeader/StretchHeader/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // StretchHeader 4 | // 5 | // Created by yumlive0909 on 15/9/9. 6 | // Copyright (c) 2015年 yumlive0909. 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 | -------------------------------------------------------------------------------- /StretchHeader/StretchHeader/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // StretchHeader 4 | // 5 | // Created by yumlive0909 on 15/9/9. 6 | // Copyright (c) 2015年 yumlive0909. 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 | 21 | return YES; 22 | } 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // 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. 26 | // 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. 27 | } 28 | 29 | - (void)applicationDidEnterBackground:(UIApplication *)application { 30 | // 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. 31 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 32 | } 33 | 34 | - (void)applicationWillEnterForeground:(UIApplication *)application { 35 | // 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. 36 | } 37 | 38 | - (void)applicationDidBecomeActive:(UIApplication *)application { 39 | // 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. 40 | } 41 | 42 | - (void)applicationWillTerminate:(UIApplication *)application { 43 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /StretchHeader/StretchHeader/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /StretchHeader/StretchHeader/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /StretchHeader/StretchHeader/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 | } -------------------------------------------------------------------------------- /StretchHeader/StretchHeader/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.yumlive.$(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 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /StretchHeader/StretchHeader/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // StretchHeader 4 | // 5 | // Created by yumlive0909 on 15/9/9. 6 | // Copyright (c) 2015年 yumlive0909. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /StretchHeader/StretchHeader/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // StretchHeader 4 | // 5 | // Created by yumlive0909 on 15/9/9. 6 | // Copyright (c) 2015年 yumlive0909. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "HFStretchableTableHeaderView.h" 11 | 12 | #define StretchHeaderHeight 200 13 | 14 | @interface ViewController () 15 | 16 | @property (nonatomic,strong)UITableView *mineTable; 17 | @property (nonatomic,strong)HFStretchableTableHeaderView *stretchHeaderView; 18 | 19 | @end 20 | 21 | @implementation ViewController 22 | 23 | - (UITableView *)mineTable 24 | { 25 | if (_mineTable == nil) { 26 | _mineTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height) style:UITableViewStylePlain]; 27 | _mineTable.delegate = self; 28 | _mineTable.dataSource = self; 29 | _mineTable.showsVerticalScrollIndicator = NO; 30 | [self.view addSubview:_mineTable]; 31 | } 32 | return _mineTable; 33 | } 34 | 35 | 36 | - (void)viewDidLoad { 37 | [super viewDidLoad]; 38 | // Do any additional setup after loading the view, typically from a nib. 39 | 40 | self.title = @"我的"; 41 | self.automaticallyAdjustsScrollViewInsets = NO; 42 | 43 | 44 | [self mineTable]; 45 | 46 | [self initStretchHeader]; 47 | 48 | } 49 | 50 | 51 | - (void)initStretchHeader 52 | { 53 | //背景 54 | UIImageView *bgImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, StretchHeaderHeight)]; 55 | bgImageView.contentMode = UIViewContentModeScaleAspectFill; 56 | bgImageView.clipsToBounds = YES; 57 | bgImageView.image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"photo" ofType:@"jpg"]]; 58 | 59 | //背景之上的内容 60 | UIView *contentView = [[UIView alloc] initWithFrame:bgImageView.bounds]; 61 | contentView.backgroundColor = [UIColor clearColor]; 62 | 63 | /* 64 | UIImageView *avater = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 90, 90)]; 65 | avater.image = [UIImage imageNamed:@"avater"]; 66 | avater.center = contentView.center; 67 | [contentView addSubview:avater]; 68 | */ 69 | 70 | self.stretchHeaderView = [HFStretchableTableHeaderView new]; 71 | [self.stretchHeaderView stretchHeaderForTableView:self.mineTable withView:bgImageView subViews:contentView]; 72 | 73 | } 74 | 75 | 76 | - (void)didReceiveMemoryWarning { 77 | [super didReceiveMemoryWarning]; 78 | // Dispose of any resources that can be recreated. 79 | } 80 | 81 | #pragma mark - table delegate 82 | 83 | -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 84 | { 85 | return 40; 86 | } 87 | 88 | -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 89 | { 90 | return 20; 91 | } 92 | -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 93 | { 94 | static NSString *cellId = @"reuseCell"; 95 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId ]; 96 | if (!cell) { 97 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId]; 98 | } 99 | cell.textLabel.textAlignment = NSTextAlignmentCenter; 100 | cell.textLabel.text = [NSString stringWithFormat:@"%ld",indexPath.row]; 101 | return cell; 102 | } 103 | 104 | -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 105 | { 106 | [tableView deselectRowAtIndexPath:indexPath animated:YES]; 107 | } 108 | 109 | 110 | 111 | #pragma mark - stretchableTable delegate 112 | 113 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView 114 | { 115 | [self.stretchHeaderView scrollViewDidScroll:scrollView]; 116 | } 117 | 118 | - (void)viewDidLayoutSubviews 119 | { 120 | [self.stretchHeaderView resizeView]; 121 | } 122 | 123 | @end 124 | -------------------------------------------------------------------------------- /StretchHeader/StretchHeader/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // StretchHeader 4 | // 5 | // Created by yumlive0909 on 15/9/9. 6 | // Copyright (c) 2015年 yumlive0909. 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 | -------------------------------------------------------------------------------- /StretchHeader/StretchHeader/resources/avater@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljhang/StretchHeader/15beafa4788c41d92fe132fa11138d3ed2216178/StretchHeader/StretchHeader/resources/avater@2x.png -------------------------------------------------------------------------------- /StretchHeader/StretchHeader/resources/photo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljhang/StretchHeader/15beafa4788c41d92fe132fa11138d3ed2216178/StretchHeader/StretchHeader/resources/photo.jpg -------------------------------------------------------------------------------- /StretchHeader/StretchHeader/stretchTableHeader/HFStretchableTableHeaderView.h: -------------------------------------------------------------------------------- 1 | // 2 | // StretchableTableHeaderView.h 3 | // StretchableTableHeaderView 4 | // 5 | 6 | #import 7 | #import 8 | 9 | @interface HFStretchableTableHeaderView : NSObject 10 | 11 | @property (nonatomic,retain) UITableView* tableView; 12 | @property (nonatomic,retain) UIView* view; 13 | 14 | 15 | /** 16 | * subview:内容部分 17 | * view :拉伸的背景图片 18 | */ 19 | - (void)stretchHeaderForTableView:(UITableView*)tableView 20 | withView:(UIView*)view 21 | subViews:(UIView*)subview; 22 | 23 | - (void)scrollViewDidScroll:(UIScrollView*)scrollView; 24 | 25 | - (void)resizeView; 26 | 27 | @end 28 | 29 | /* 30 | *使用时要实现以下两个代理方法 31 | *- (void)scrollViewDidScroll:(UIScrollView *)scrollView 32 | *- (void)viewDidLayoutSubviews 33 | */ -------------------------------------------------------------------------------- /StretchHeader/StretchHeader/stretchTableHeader/HFStretchableTableHeaderView.m: -------------------------------------------------------------------------------- 1 | // 2 | // StretchableTableHeaderView.m 3 | // StretchableTableHeaderView 4 | // 5 | 6 | #import "HFStretchableTableHeaderView.h" 7 | 8 | 9 | @interface HFStretchableTableHeaderView() 10 | { 11 | CGRect initialFrame; 12 | CGFloat defaultViewHeight; 13 | } 14 | @end 15 | 16 | 17 | @implementation HFStretchableTableHeaderView 18 | 19 | @synthesize tableView = _tableView; 20 | @synthesize view = _view; 21 | 22 | 23 | 24 | - (void)stretchHeaderForTableView:(UITableView*)tableView withView:(UIView*)view subViews:(UIView*)subview 25 | { 26 | _tableView = tableView; 27 | _view = view; 28 | 29 | initialFrame = _view.frame; 30 | defaultViewHeight = initialFrame.size.height; 31 | 32 | UIView *emptyTableHeaderView = [[UIView alloc] initWithFrame:initialFrame]; 33 | 34 | _tableView.tableHeaderView = emptyTableHeaderView; 35 | 36 | [_tableView addSubview:_view]; 37 | [_tableView addSubview:subview]; 38 | } 39 | 40 | - (void)scrollViewDidScroll:(UIScrollView*)scrollView 41 | { 42 | CGRect f = _view.frame; 43 | f.size.width = _tableView.frame.size.width; 44 | _view.frame = f; 45 | 46 | if(scrollView.contentOffset.y < 0) 47 | { 48 | CGFloat offsetY = (scrollView.contentOffset.y + scrollView.contentInset.top) * -1; 49 | 50 | initialFrame.origin.y = - offsetY * 1; 51 | initialFrame.origin.x = - offsetY / 2; 52 | 53 | initialFrame.size.width = _tableView.frame.size.width + offsetY; 54 | initialFrame.size.height = defaultViewHeight + offsetY; 55 | 56 | _view.frame = initialFrame; 57 | } 58 | 59 | } 60 | 61 | 62 | - (void)resizeView 63 | { 64 | initialFrame.size.width = _tableView.frame.size.width; 65 | _view.frame = initialFrame; 66 | } 67 | 68 | 69 | @end 70 | -------------------------------------------------------------------------------- /StretchHeader/StretchHeaderTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.yumlive.$(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 | -------------------------------------------------------------------------------- /StretchHeader/StretchHeaderTests/StretchHeaderTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // StretchHeaderTests.m 3 | // StretchHeaderTests 4 | // 5 | // Created by yumlive0909 on 15/9/9. 6 | // Copyright (c) 2015年 yumlive0909. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface StretchHeaderTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation StretchHeaderTests 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 | -------------------------------------------------------------------------------- /StretchHeader/head.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljhang/StretchHeader/15beafa4788c41d92fe132fa11138d3ed2216178/StretchHeader/head.gif -------------------------------------------------------------------------------- /head.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljhang/StretchHeader/15beafa4788c41d92fe132fa11138d3ed2216178/head.gif --------------------------------------------------------------------------------