├── .gitignore ├── ExpandableTableView.gif ├── README.md ├── Sample.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── Sample ├── AppDelegate.swift ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json ├── Info.plist └── ViewController.swift ├── SampleTests ├── Info.plist └── SampleTests.swift └── UIExpandableTableView ├── HeaderView.swift └── UIExpandableTableView.swift /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | .DS_Store 4 | *.swp 5 | *~.nib 6 | build/ 7 | *.pbxuser 8 | !default.pbxuser 9 | *.mode1v3 10 | !default.mode1v3 11 | *.mode2v3 12 | !default.mode2v3 13 | *.perspectivev3 14 | !default.perspectivev3 15 | xcuserdata 16 | *.xccheckout 17 | *.moved-aside 18 | DerivedData 19 | *.hmap 20 | *.ipa 21 | *.xcuserstate 22 | 23 | # CocoaPods 24 | # 25 | # We recommend against adding the Pods directory to your .gitignore. However 26 | # you should judge for yourself, the pros and cons are mentioned at: 27 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 28 | # 29 | #Pods/ 30 | -------------------------------------------------------------------------------- /ExpandableTableView.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rondinellimorais/ExpandableTableView/510a46d16389a7a35742a077f24e791b7a419ead/ExpandableTableView.gif -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ExpandableTableView 2 | This is a subclass of `UITableView` where you can expand the header. 3 | Download the project and see the example. 4 | 5 |
6 |

7 |
8 | -------------------------------------------------------------------------------- /Sample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 18D721EA1BA8A1E300F5DF4C /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18D721E91BA8A1E300F5DF4C /* AppDelegate.swift */; }; 11 | 18D721EC1BA8A1E300F5DF4C /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18D721EB1BA8A1E300F5DF4C /* ViewController.swift */; }; 12 | 18D721EF1BA8A1E300F5DF4C /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 18D721ED1BA8A1E300F5DF4C /* Main.storyboard */; }; 13 | 18D721F11BA8A1E300F5DF4C /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 18D721F01BA8A1E300F5DF4C /* Images.xcassets */; }; 14 | 18D721F41BA8A1E300F5DF4C /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 18D721F21BA8A1E300F5DF4C /* LaunchScreen.xib */; }; 15 | 18D722001BA8A1E300F5DF4C /* SampleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18D721FF1BA8A1E300F5DF4C /* SampleTests.swift */; }; 16 | 18D7220C1BA8A42B00F5DF4C /* HeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18D7220A1BA8A42B00F5DF4C /* HeaderView.swift */; }; 17 | 18D7220D1BA8A42B00F5DF4C /* UIExpandableTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18D7220B1BA8A42B00F5DF4C /* UIExpandableTableView.swift */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXContainerItemProxy section */ 21 | 18D721FA1BA8A1E300F5DF4C /* PBXContainerItemProxy */ = { 22 | isa = PBXContainerItemProxy; 23 | containerPortal = 18D721DC1BA8A1E300F5DF4C /* Project object */; 24 | proxyType = 1; 25 | remoteGlobalIDString = 18D721E31BA8A1E300F5DF4C; 26 | remoteInfo = Sample; 27 | }; 28 | /* End PBXContainerItemProxy section */ 29 | 30 | /* Begin PBXFileReference section */ 31 | 18D721E41BA8A1E300F5DF4C /* Sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Sample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 32 | 18D721E81BA8A1E300F5DF4C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 33 | 18D721E91BA8A1E300F5DF4C /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 34 | 18D721EB1BA8A1E300F5DF4C /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 35 | 18D721EE1BA8A1E300F5DF4C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 36 | 18D721F01BA8A1E300F5DF4C /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 37 | 18D721F31BA8A1E300F5DF4C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 38 | 18D721F91BA8A1E300F5DF4C /* SampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 39 | 18D721FE1BA8A1E300F5DF4C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 40 | 18D721FF1BA8A1E300F5DF4C /* SampleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SampleTests.swift; sourceTree = ""; }; 41 | 18D7220A1BA8A42B00F5DF4C /* HeaderView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeaderView.swift; sourceTree = ""; }; 42 | 18D7220B1BA8A42B00F5DF4C /* UIExpandableTableView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIExpandableTableView.swift; sourceTree = ""; }; 43 | /* End PBXFileReference section */ 44 | 45 | /* Begin PBXFrameworksBuildPhase section */ 46 | 18D721E11BA8A1E300F5DF4C /* Frameworks */ = { 47 | isa = PBXFrameworksBuildPhase; 48 | buildActionMask = 2147483647; 49 | files = ( 50 | ); 51 | runOnlyForDeploymentPostprocessing = 0; 52 | }; 53 | 18D721F61BA8A1E300F5DF4C /* Frameworks */ = { 54 | isa = PBXFrameworksBuildPhase; 55 | buildActionMask = 2147483647; 56 | files = ( 57 | ); 58 | runOnlyForDeploymentPostprocessing = 0; 59 | }; 60 | /* End PBXFrameworksBuildPhase section */ 61 | 62 | /* Begin PBXGroup section */ 63 | 18D721DB1BA8A1E300F5DF4C = { 64 | isa = PBXGroup; 65 | children = ( 66 | 18D721E61BA8A1E300F5DF4C /* Sample */, 67 | 18D721FC1BA8A1E300F5DF4C /* SampleTests */, 68 | 18D721E51BA8A1E300F5DF4C /* Products */, 69 | ); 70 | sourceTree = ""; 71 | }; 72 | 18D721E51BA8A1E300F5DF4C /* Products */ = { 73 | isa = PBXGroup; 74 | children = ( 75 | 18D721E41BA8A1E300F5DF4C /* Sample.app */, 76 | 18D721F91BA8A1E300F5DF4C /* SampleTests.xctest */, 77 | ); 78 | name = Products; 79 | sourceTree = ""; 80 | }; 81 | 18D721E61BA8A1E300F5DF4C /* Sample */ = { 82 | isa = PBXGroup; 83 | children = ( 84 | 18D722091BA8A42B00F5DF4C /* UIExpandableTableView */, 85 | 18D721E91BA8A1E300F5DF4C /* AppDelegate.swift */, 86 | 18D721EB1BA8A1E300F5DF4C /* ViewController.swift */, 87 | 18D721ED1BA8A1E300F5DF4C /* Main.storyboard */, 88 | 18D721F01BA8A1E300F5DF4C /* Images.xcassets */, 89 | 18D721F21BA8A1E300F5DF4C /* LaunchScreen.xib */, 90 | 18D721E71BA8A1E300F5DF4C /* Supporting Files */, 91 | ); 92 | path = Sample; 93 | sourceTree = ""; 94 | }; 95 | 18D721E71BA8A1E300F5DF4C /* Supporting Files */ = { 96 | isa = PBXGroup; 97 | children = ( 98 | 18D721E81BA8A1E300F5DF4C /* Info.plist */, 99 | ); 100 | name = "Supporting Files"; 101 | sourceTree = ""; 102 | }; 103 | 18D721FC1BA8A1E300F5DF4C /* SampleTests */ = { 104 | isa = PBXGroup; 105 | children = ( 106 | 18D721FF1BA8A1E300F5DF4C /* SampleTests.swift */, 107 | 18D721FD1BA8A1E300F5DF4C /* Supporting Files */, 108 | ); 109 | path = SampleTests; 110 | sourceTree = ""; 111 | }; 112 | 18D721FD1BA8A1E300F5DF4C /* Supporting Files */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | 18D721FE1BA8A1E300F5DF4C /* Info.plist */, 116 | ); 117 | name = "Supporting Files"; 118 | sourceTree = ""; 119 | }; 120 | 18D722091BA8A42B00F5DF4C /* UIExpandableTableView */ = { 121 | isa = PBXGroup; 122 | children = ( 123 | 18D7220A1BA8A42B00F5DF4C /* HeaderView.swift */, 124 | 18D7220B1BA8A42B00F5DF4C /* UIExpandableTableView.swift */, 125 | ); 126 | path = UIExpandableTableView; 127 | sourceTree = SOURCE_ROOT; 128 | }; 129 | /* End PBXGroup section */ 130 | 131 | /* Begin PBXNativeTarget section */ 132 | 18D721E31BA8A1E300F5DF4C /* Sample */ = { 133 | isa = PBXNativeTarget; 134 | buildConfigurationList = 18D722031BA8A1E300F5DF4C /* Build configuration list for PBXNativeTarget "Sample" */; 135 | buildPhases = ( 136 | 18D721E01BA8A1E300F5DF4C /* Sources */, 137 | 18D721E11BA8A1E300F5DF4C /* Frameworks */, 138 | 18D721E21BA8A1E300F5DF4C /* Resources */, 139 | ); 140 | buildRules = ( 141 | ); 142 | dependencies = ( 143 | ); 144 | name = Sample; 145 | productName = Sample; 146 | productReference = 18D721E41BA8A1E300F5DF4C /* Sample.app */; 147 | productType = "com.apple.product-type.application"; 148 | }; 149 | 18D721F81BA8A1E300F5DF4C /* SampleTests */ = { 150 | isa = PBXNativeTarget; 151 | buildConfigurationList = 18D722061BA8A1E300F5DF4C /* Build configuration list for PBXNativeTarget "SampleTests" */; 152 | buildPhases = ( 153 | 18D721F51BA8A1E300F5DF4C /* Sources */, 154 | 18D721F61BA8A1E300F5DF4C /* Frameworks */, 155 | 18D721F71BA8A1E300F5DF4C /* Resources */, 156 | ); 157 | buildRules = ( 158 | ); 159 | dependencies = ( 160 | 18D721FB1BA8A1E300F5DF4C /* PBXTargetDependency */, 161 | ); 162 | name = SampleTests; 163 | productName = SampleTests; 164 | productReference = 18D721F91BA8A1E300F5DF4C /* SampleTests.xctest */; 165 | productType = "com.apple.product-type.bundle.unit-test"; 166 | }; 167 | /* End PBXNativeTarget section */ 168 | 169 | /* Begin PBXProject section */ 170 | 18D721DC1BA8A1E300F5DF4C /* Project object */ = { 171 | isa = PBXProject; 172 | attributes = { 173 | LastUpgradeCheck = 0920; 174 | ORGANIZATIONNAME = "Rondinelli Morais"; 175 | TargetAttributes = { 176 | 18D721E31BA8A1E300F5DF4C = { 177 | CreatedOnToolsVersion = 6.4; 178 | LastSwiftMigration = 0830; 179 | ProvisioningStyle = Automatic; 180 | }; 181 | 18D721F81BA8A1E300F5DF4C = { 182 | CreatedOnToolsVersion = 6.4; 183 | LastSwiftMigration = 0920; 184 | TestTargetID = 18D721E31BA8A1E300F5DF4C; 185 | }; 186 | }; 187 | }; 188 | buildConfigurationList = 18D721DF1BA8A1E300F5DF4C /* Build configuration list for PBXProject "Sample" */; 189 | compatibilityVersion = "Xcode 3.2"; 190 | developmentRegion = English; 191 | hasScannedForEncodings = 0; 192 | knownRegions = ( 193 | en, 194 | Base, 195 | ); 196 | mainGroup = 18D721DB1BA8A1E300F5DF4C; 197 | productRefGroup = 18D721E51BA8A1E300F5DF4C /* Products */; 198 | projectDirPath = ""; 199 | projectRoot = ""; 200 | targets = ( 201 | 18D721E31BA8A1E300F5DF4C /* Sample */, 202 | 18D721F81BA8A1E300F5DF4C /* SampleTests */, 203 | ); 204 | }; 205 | /* End PBXProject section */ 206 | 207 | /* Begin PBXResourcesBuildPhase section */ 208 | 18D721E21BA8A1E300F5DF4C /* Resources */ = { 209 | isa = PBXResourcesBuildPhase; 210 | buildActionMask = 2147483647; 211 | files = ( 212 | 18D721EF1BA8A1E300F5DF4C /* Main.storyboard in Resources */, 213 | 18D721F41BA8A1E300F5DF4C /* LaunchScreen.xib in Resources */, 214 | 18D721F11BA8A1E300F5DF4C /* Images.xcassets in Resources */, 215 | ); 216 | runOnlyForDeploymentPostprocessing = 0; 217 | }; 218 | 18D721F71BA8A1E300F5DF4C /* Resources */ = { 219 | isa = PBXResourcesBuildPhase; 220 | buildActionMask = 2147483647; 221 | files = ( 222 | ); 223 | runOnlyForDeploymentPostprocessing = 0; 224 | }; 225 | /* End PBXResourcesBuildPhase section */ 226 | 227 | /* Begin PBXSourcesBuildPhase section */ 228 | 18D721E01BA8A1E300F5DF4C /* Sources */ = { 229 | isa = PBXSourcesBuildPhase; 230 | buildActionMask = 2147483647; 231 | files = ( 232 | 18D721EC1BA8A1E300F5DF4C /* ViewController.swift in Sources */, 233 | 18D7220C1BA8A42B00F5DF4C /* HeaderView.swift in Sources */, 234 | 18D721EA1BA8A1E300F5DF4C /* AppDelegate.swift in Sources */, 235 | 18D7220D1BA8A42B00F5DF4C /* UIExpandableTableView.swift in Sources */, 236 | ); 237 | runOnlyForDeploymentPostprocessing = 0; 238 | }; 239 | 18D721F51BA8A1E300F5DF4C /* Sources */ = { 240 | isa = PBXSourcesBuildPhase; 241 | buildActionMask = 2147483647; 242 | files = ( 243 | 18D722001BA8A1E300F5DF4C /* SampleTests.swift in Sources */, 244 | ); 245 | runOnlyForDeploymentPostprocessing = 0; 246 | }; 247 | /* End PBXSourcesBuildPhase section */ 248 | 249 | /* Begin PBXTargetDependency section */ 250 | 18D721FB1BA8A1E300F5DF4C /* PBXTargetDependency */ = { 251 | isa = PBXTargetDependency; 252 | target = 18D721E31BA8A1E300F5DF4C /* Sample */; 253 | targetProxy = 18D721FA1BA8A1E300F5DF4C /* PBXContainerItemProxy */; 254 | }; 255 | /* End PBXTargetDependency section */ 256 | 257 | /* Begin PBXVariantGroup section */ 258 | 18D721ED1BA8A1E300F5DF4C /* Main.storyboard */ = { 259 | isa = PBXVariantGroup; 260 | children = ( 261 | 18D721EE1BA8A1E300F5DF4C /* Base */, 262 | ); 263 | name = Main.storyboard; 264 | sourceTree = ""; 265 | }; 266 | 18D721F21BA8A1E300F5DF4C /* LaunchScreen.xib */ = { 267 | isa = PBXVariantGroup; 268 | children = ( 269 | 18D721F31BA8A1E300F5DF4C /* Base */, 270 | ); 271 | name = LaunchScreen.xib; 272 | sourceTree = ""; 273 | }; 274 | /* End PBXVariantGroup section */ 275 | 276 | /* Begin XCBuildConfiguration section */ 277 | 18D722011BA8A1E300F5DF4C /* Debug */ = { 278 | isa = XCBuildConfiguration; 279 | buildSettings = { 280 | ALWAYS_SEARCH_USER_PATHS = NO; 281 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 282 | CLANG_CXX_LIBRARY = "libc++"; 283 | CLANG_ENABLE_MODULES = YES; 284 | CLANG_ENABLE_OBJC_ARC = YES; 285 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 286 | CLANG_WARN_BOOL_CONVERSION = YES; 287 | CLANG_WARN_COMMA = YES; 288 | CLANG_WARN_CONSTANT_CONVERSION = YES; 289 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 290 | CLANG_WARN_EMPTY_BODY = YES; 291 | CLANG_WARN_ENUM_CONVERSION = YES; 292 | CLANG_WARN_INFINITE_RECURSION = YES; 293 | CLANG_WARN_INT_CONVERSION = YES; 294 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 295 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 296 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 297 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 298 | CLANG_WARN_STRICT_PROTOTYPES = YES; 299 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 300 | CLANG_WARN_UNREACHABLE_CODE = YES; 301 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 302 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 303 | COPY_PHASE_STRIP = NO; 304 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 305 | ENABLE_STRICT_OBJC_MSGSEND = YES; 306 | ENABLE_TESTABILITY = YES; 307 | GCC_C_LANGUAGE_STANDARD = gnu99; 308 | GCC_DYNAMIC_NO_PIC = NO; 309 | GCC_NO_COMMON_BLOCKS = YES; 310 | GCC_OPTIMIZATION_LEVEL = 0; 311 | GCC_PREPROCESSOR_DEFINITIONS = ( 312 | "DEBUG=1", 313 | "$(inherited)", 314 | ); 315 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 316 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 317 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 318 | GCC_WARN_UNDECLARED_SELECTOR = YES; 319 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 320 | GCC_WARN_UNUSED_FUNCTION = YES; 321 | GCC_WARN_UNUSED_VARIABLE = YES; 322 | IPHONEOS_DEPLOYMENT_TARGET = 8.4; 323 | MTL_ENABLE_DEBUG_INFO = YES; 324 | ONLY_ACTIVE_ARCH = YES; 325 | SDKROOT = iphoneos; 326 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 327 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 328 | SWIFT_VERSION = 4.0; 329 | }; 330 | name = Debug; 331 | }; 332 | 18D722021BA8A1E300F5DF4C /* Release */ = { 333 | isa = XCBuildConfiguration; 334 | buildSettings = { 335 | ALWAYS_SEARCH_USER_PATHS = NO; 336 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 337 | CLANG_CXX_LIBRARY = "libc++"; 338 | CLANG_ENABLE_MODULES = YES; 339 | CLANG_ENABLE_OBJC_ARC = YES; 340 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 341 | CLANG_WARN_BOOL_CONVERSION = YES; 342 | CLANG_WARN_COMMA = YES; 343 | CLANG_WARN_CONSTANT_CONVERSION = YES; 344 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 345 | CLANG_WARN_EMPTY_BODY = YES; 346 | CLANG_WARN_ENUM_CONVERSION = YES; 347 | CLANG_WARN_INFINITE_RECURSION = YES; 348 | CLANG_WARN_INT_CONVERSION = YES; 349 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 350 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 351 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 352 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 353 | CLANG_WARN_STRICT_PROTOTYPES = YES; 354 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 355 | CLANG_WARN_UNREACHABLE_CODE = YES; 356 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 357 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 358 | COPY_PHASE_STRIP = NO; 359 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 360 | ENABLE_NS_ASSERTIONS = NO; 361 | ENABLE_STRICT_OBJC_MSGSEND = YES; 362 | GCC_C_LANGUAGE_STANDARD = gnu99; 363 | GCC_NO_COMMON_BLOCKS = YES; 364 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 365 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 366 | GCC_WARN_UNDECLARED_SELECTOR = YES; 367 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 368 | GCC_WARN_UNUSED_FUNCTION = YES; 369 | GCC_WARN_UNUSED_VARIABLE = YES; 370 | IPHONEOS_DEPLOYMENT_TARGET = 8.4; 371 | MTL_ENABLE_DEBUG_INFO = NO; 372 | SDKROOT = iphoneos; 373 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 374 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 375 | SWIFT_VERSION = 4.0; 376 | VALIDATE_PRODUCT = YES; 377 | }; 378 | name = Release; 379 | }; 380 | 18D722041BA8A1E300F5DF4C /* Debug */ = { 381 | isa = XCBuildConfiguration; 382 | buildSettings = { 383 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 384 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 385 | CODE_SIGN_STYLE = Automatic; 386 | DEVELOPMENT_TEAM = ""; 387 | INFOPLIST_FILE = Sample/Info.plist; 388 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 389 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 390 | PRODUCT_BUNDLE_IDENTIFIER = br.com.portoseguro.conectacenter; 391 | PRODUCT_NAME = "$(TARGET_NAME)"; 392 | PROVISIONING_PROFILE = ""; 393 | PROVISIONING_PROFILE_SPECIFIER = ""; 394 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 395 | SWIFT_VERSION = 4.0; 396 | }; 397 | name = Debug; 398 | }; 399 | 18D722051BA8A1E300F5DF4C /* Release */ = { 400 | isa = XCBuildConfiguration; 401 | buildSettings = { 402 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 403 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 404 | CODE_SIGN_STYLE = Automatic; 405 | DEVELOPMENT_TEAM = ""; 406 | INFOPLIST_FILE = Sample/Info.plist; 407 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 408 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 409 | PRODUCT_BUNDLE_IDENTIFIER = br.com.portoseguro.conectacenter; 410 | PRODUCT_NAME = "$(TARGET_NAME)"; 411 | PROVISIONING_PROFILE_SPECIFIER = ""; 412 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 413 | SWIFT_VERSION = 4.0; 414 | }; 415 | name = Release; 416 | }; 417 | 18D722071BA8A1E300F5DF4C /* Debug */ = { 418 | isa = XCBuildConfiguration; 419 | buildSettings = { 420 | BUNDLE_LOADER = "$(TEST_HOST)"; 421 | FRAMEWORK_SEARCH_PATHS = ( 422 | "$(SDKROOT)/Developer/Library/Frameworks", 423 | "$(inherited)", 424 | ); 425 | GCC_PREPROCESSOR_DEFINITIONS = ( 426 | "DEBUG=1", 427 | "$(inherited)", 428 | ); 429 | INFOPLIST_FILE = SampleTests/Info.plist; 430 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 431 | PRODUCT_BUNDLE_IDENTIFIER = "br.com.rondinellimorais.$(PRODUCT_NAME:rfc1034identifier)"; 432 | PRODUCT_NAME = "$(TARGET_NAME)"; 433 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 434 | SWIFT_VERSION = 3.0; 435 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Sample.app/Sample"; 436 | }; 437 | name = Debug; 438 | }; 439 | 18D722081BA8A1E300F5DF4C /* Release */ = { 440 | isa = XCBuildConfiguration; 441 | buildSettings = { 442 | BUNDLE_LOADER = "$(TEST_HOST)"; 443 | FRAMEWORK_SEARCH_PATHS = ( 444 | "$(SDKROOT)/Developer/Library/Frameworks", 445 | "$(inherited)", 446 | ); 447 | INFOPLIST_FILE = SampleTests/Info.plist; 448 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 449 | PRODUCT_BUNDLE_IDENTIFIER = "br.com.rondinellimorais.$(PRODUCT_NAME:rfc1034identifier)"; 450 | PRODUCT_NAME = "$(TARGET_NAME)"; 451 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 452 | SWIFT_VERSION = 3.0; 453 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Sample.app/Sample"; 454 | }; 455 | name = Release; 456 | }; 457 | /* End XCBuildConfiguration section */ 458 | 459 | /* Begin XCConfigurationList section */ 460 | 18D721DF1BA8A1E300F5DF4C /* Build configuration list for PBXProject "Sample" */ = { 461 | isa = XCConfigurationList; 462 | buildConfigurations = ( 463 | 18D722011BA8A1E300F5DF4C /* Debug */, 464 | 18D722021BA8A1E300F5DF4C /* Release */, 465 | ); 466 | defaultConfigurationIsVisible = 0; 467 | defaultConfigurationName = Release; 468 | }; 469 | 18D722031BA8A1E300F5DF4C /* Build configuration list for PBXNativeTarget "Sample" */ = { 470 | isa = XCConfigurationList; 471 | buildConfigurations = ( 472 | 18D722041BA8A1E300F5DF4C /* Debug */, 473 | 18D722051BA8A1E300F5DF4C /* Release */, 474 | ); 475 | defaultConfigurationIsVisible = 0; 476 | defaultConfigurationName = Release; 477 | }; 478 | 18D722061BA8A1E300F5DF4C /* Build configuration list for PBXNativeTarget "SampleTests" */ = { 479 | isa = XCConfigurationList; 480 | buildConfigurations = ( 481 | 18D722071BA8A1E300F5DF4C /* Debug */, 482 | 18D722081BA8A1E300F5DF4C /* Release */, 483 | ); 484 | defaultConfigurationIsVisible = 0; 485 | defaultConfigurationName = Release; 486 | }; 487 | /* End XCConfigurationList section */ 488 | }; 489 | rootObject = 18D721DC1BA8A1E300F5DF4C /* Project object */; 490 | } 491 | -------------------------------------------------------------------------------- /Sample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Sample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // Sample 4 | // 5 | // Created by Rondinelli Morais on 15/09/15. 6 | // Copyright (c) 2015 Rondinelli Morais. 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 | -------------------------------------------------------------------------------- /Sample/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Sample/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 | 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 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /Sample/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ios-marketing", 45 | "size" : "1024x1024", 46 | "scale" : "1x" 47 | } 48 | ], 49 | "info" : { 50 | "version" : 1, 51 | "author" : "xcode" 52 | } 53 | } -------------------------------------------------------------------------------- /Sample/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Sample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | br.com.rondinellimorais.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 2.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 | UIInterfaceOrientationPortraitUpsideDown 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Sample/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // Sample 4 | // 5 | // Created by Rondinelli Morais on 15/09/15. 6 | // Copyright (c) 2015 Rondinelli Morais. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { 12 | 13 | // MARK: Properties 14 | @IBOutlet weak var tableView:UIExpandableTableView! 15 | var items:[[Int]?] = [] 16 | 17 | //MARK: view cycle 18 | override func viewDidLoad() { 19 | super.viewDidLoad() 20 | 21 | // create data 22 | for i in 0...Int(arc4random_uniform(100)) { 23 | items.append([]) 24 | for j in 0...Int(arc4random_uniform(10)) { 25 | items[i]!.append(j) 26 | } 27 | } 28 | } 29 | 30 | // MARK: UITableViewDataSource 31 | func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { 32 | return 80 33 | } 34 | 35 | func numberOfSections(in tableView: UITableView) -> Int { 36 | return items.count 37 | } 38 | 39 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 40 | 41 | if (!items.isEmpty) { 42 | if (self.tableView.sectionOpen != NSNotFound && section == self.tableView.sectionOpen) { 43 | return items[section]!.count 44 | } 45 | } 46 | return 0 47 | } 48 | 49 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 50 | let cell = tableView.dequeueReusableCell(withIdentifier: "CellIdentifier", for: indexPath as IndexPath) 51 | cell.textLabel?.text = "section \(indexPath.section) row \(indexPath.row)" 52 | cell.textLabel?.backgroundColor = UIColor.clear 53 | return cell 54 | } 55 | 56 | // MARK: UITableViewDelegate 57 | func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { 58 | let headerView = HeaderView(tableView: self.tableView, section: section) 59 | headerView.backgroundColor = UIColor(red: CGFloat(arc4random_uniform(100)) / 100.0, 60 | green: CGFloat(arc4random_uniform(100)) / 100.0, 61 | blue: CGFloat(arc4random_uniform(255)) / 100.0, 62 | alpha: 1) 63 | 64 | let label = UILabel(frame: headerView.frame) 65 | label.text = "Section \(section), touch here!" 66 | label.textAlignment = NSTextAlignment.center 67 | label.font = UIFont(name: "HelveticaNeue-Bold", size: 18) 68 | label.textColor = UIColor.white 69 | 70 | headerView.addSubview(label) 71 | 72 | return headerView 73 | } 74 | 75 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 76 | tableView.deselectRow(at: indexPath as IndexPath, animated: true) 77 | } 78 | } 79 | 80 | -------------------------------------------------------------------------------- /SampleTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /SampleTests/SampleTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SampleTests.swift 3 | // SampleTests 4 | // 5 | // Created by Rondinelli Morais on 15/09/15. 6 | // Copyright (c) 2015 Rondinelli Morais. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import XCTest 11 | 12 | class SampleTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | XCTAssert(true, "Pass") 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measure() { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /UIExpandableTableView/HeaderView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HeaderView.swift 3 | // LabelTeste 4 | // 5 | // Created by Rondinelli Morais on 11/09/15. 6 | // Copyright (c) 2015 Rondinelli Morais. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | protocol HeaderViewDelegate: NSObjectProtocol { 12 | func headerViewOpen(_ section:Int) 13 | func headerViewClose(_ section:Int) 14 | } 15 | 16 | class HeaderView: UIView { 17 | 18 | var delegate:HeaderViewDelegate? 19 | var section:Int? 20 | var tableView:UIExpandableTableView? 21 | 22 | required init(tableView:UIExpandableTableView, section:Int){ 23 | 24 | let height = tableView.delegate?.tableView!(tableView, heightForHeaderInSection: section) 25 | let frame = CGRect(x: 0, y: 0, width: tableView.frame.width, height: height!) 26 | 27 | super.init(frame: frame) 28 | 29 | self.tableView = tableView 30 | self.delegate = tableView 31 | self.section = section 32 | 33 | if #available(iOS 11, *) { 34 | self.tableView.estimatedRowHeight = 0; 35 | self.tableView.estimatedSectionHeaderHeight = 0; 36 | self.tableView.estimatedSectionFooterHeight = 0; 37 | } 38 | } 39 | } 40 | 41 | required init(coder aDecoder: NSCoder) { 42 | fatalError("init(coder:) has not been implemented") 43 | } 44 | 45 | override func layoutSubviews() { 46 | let toggleButton = UIButton() 47 | toggleButton.addTarget(self, action: #selector(HeaderView.toggle(_:)), for: UIControlEvents.touchUpInside) 48 | toggleButton.backgroundColor = UIColor.clear 49 | toggleButton.frame = CGRect(x: 0, y: 0, width: self.frame.width, height: self.frame.height) 50 | self.addSubview(toggleButton) 51 | } 52 | 53 | @objc func toggle(_ sender:AnyObject){ 54 | 55 | if self.tableView!.sectionOpen != section! { 56 | self.delegate?.headerViewOpen(section!) 57 | } else if self.tableView!.sectionOpen != NSNotFound { 58 | self.delegate?.headerViewClose(self.tableView!.sectionOpen) 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /UIExpandableTableView/UIExpandableTableView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIExpandableTableView.swift 3 | // LabelTeste 4 | // 5 | // Created by Rondinelli Morais on 11/09/15. 6 | // Copyright (c) 2015 Rondinelli Morais. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class UIExpandableTableView : UITableView, HeaderViewDelegate { 12 | 13 | var sectionOpen:Int = NSNotFound 14 | 15 | // MARK: HeaderViewDelegate 16 | func headerViewOpen(_ section: Int) { 17 | 18 | if self.sectionOpen != NSNotFound { 19 | headerViewClose(self.sectionOpen) 20 | } 21 | 22 | self.sectionOpen = section 23 | let numberOfRows = self.dataSource?.tableView(self, numberOfRowsInSection: section) 24 | var indexesPathToInsert:[IndexPath] = [] 25 | 26 | for i in 0.. 0 { 31 | self.beginUpdates() 32 | self.insertRows(at: indexesPathToInsert, with: UITableViewRowAnimation.automatic) 33 | self.endUpdates() 34 | } 35 | } 36 | 37 | func headerViewClose(_ section: Int) { 38 | 39 | let numberOfRows = self.dataSource?.tableView(self, numberOfRowsInSection: section) 40 | var indexesPathToDelete:[IndexPath] = [] 41 | self.sectionOpen = NSNotFound 42 | 43 | for i in 0.. 0 { 48 | self.beginUpdates() 49 | self.deleteRows(at: indexesPathToDelete, with: UITableViewRowAnimation.top) 50 | self.endUpdates() 51 | } 52 | } 53 | } 54 | --------------------------------------------------------------------------------