├── CollectionView.gif ├── README.md └── RTCollectionViewGroup ├── RTCollectionViewGroup.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── Rabbit.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── Rabbit.xcuserdatad │ └── xcschemes │ ├── RTCollectionViewGroup.xcscheme │ └── xcschememanagement.plist ├── RTCollectionViewGroup ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── GroupCollectionCell.h ├── GroupCollectionCell.m ├── GroupCollectionCell.xib ├── GroupSection.h ├── GroupSection.m ├── GroupSection.xib ├── Info.plist ├── ViewController.h ├── ViewController.m ├── btn_menu@2x.png ├── btn_menu_normal@2x.png └── main.m ├── RTCollectionViewGroupTests ├── Info.plist └── RTCollectionViewGroupTests.m └── RTCollectionViewGroupUITests ├── Info.plist └── RTCollectionViewGroupUITests.m /CollectionView.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeRabbitYu/RTCollectionViewGroup/e4ecb6a139780ecff7ff61d1bc7923f8798929a9/CollectionView.gif -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RTCollectionViewGroup 2 | Grouping of about collectionView 3 | 用简单的代码实现了CollectionView的分组功能,本人愚笨不太会封装,所以把注释写的很清楚,可以直接拿去使用. 4 | 5 | ![image](https://github.com/RabbitBell/RTCollectionViewGroup/raw/master/CollectionView.gif) -------------------------------------------------------------------------------- /RTCollectionViewGroup/RTCollectionViewGroup.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 33B21FC01C9409C2002FBFBF /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 33B21FBF1C9409C2002FBFBF /* main.m */; }; 11 | 33B21FC31C9409C2002FBFBF /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 33B21FC21C9409C2002FBFBF /* AppDelegate.m */; }; 12 | 33B21FC61C9409C2002FBFBF /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 33B21FC51C9409C2002FBFBF /* ViewController.m */; }; 13 | 33B21FC91C9409C2002FBFBF /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 33B21FC71C9409C2002FBFBF /* Main.storyboard */; }; 14 | 33B21FCB1C9409C2002FBFBF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33B21FCA1C9409C2002FBFBF /* Assets.xcassets */; }; 15 | 33B21FCE1C9409C2002FBFBF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 33B21FCC1C9409C2002FBFBF /* LaunchScreen.storyboard */; }; 16 | 33B21FD91C9409C2002FBFBF /* RTCollectionViewGroupTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 33B21FD81C9409C2002FBFBF /* RTCollectionViewGroupTests.m */; }; 17 | 33B21FE41C9409C2002FBFBF /* RTCollectionViewGroupUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 33B21FE31C9409C2002FBFBF /* RTCollectionViewGroupUITests.m */; }; 18 | 33B21FF41C940A5D002FBFBF /* GroupCollectionCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 33B21FF21C940A5D002FBFBF /* GroupCollectionCell.m */; }; 19 | 33B21FF51C940A5D002FBFBF /* GroupCollectionCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33B21FF31C940A5D002FBFBF /* GroupCollectionCell.xib */; }; 20 | 33B21FF91C940B4A002FBFBF /* GroupSection.m in Sources */ = {isa = PBXBuildFile; fileRef = 33B21FF71C940B4A002FBFBF /* GroupSection.m */; }; 21 | 33B21FFA1C940B4A002FBFBF /* GroupSection.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33B21FF81C940B4A002FBFBF /* GroupSection.xib */; }; 22 | 33B21FFD1C940D7D002FBFBF /* btn_menu_normal@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 33B21FFB1C940D7D002FBFBF /* btn_menu_normal@2x.png */; }; 23 | 33B21FFE1C940D7D002FBFBF /* btn_menu@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 33B21FFC1C940D7D002FBFBF /* btn_menu@2x.png */; }; 24 | /* End PBXBuildFile section */ 25 | 26 | /* Begin PBXContainerItemProxy section */ 27 | 33B21FD51C9409C2002FBFBF /* PBXContainerItemProxy */ = { 28 | isa = PBXContainerItemProxy; 29 | containerPortal = 33B21FB31C9409C2002FBFBF /* Project object */; 30 | proxyType = 1; 31 | remoteGlobalIDString = 33B21FBA1C9409C2002FBFBF; 32 | remoteInfo = RTCollectionViewGroup; 33 | }; 34 | 33B21FE01C9409C2002FBFBF /* PBXContainerItemProxy */ = { 35 | isa = PBXContainerItemProxy; 36 | containerPortal = 33B21FB31C9409C2002FBFBF /* Project object */; 37 | proxyType = 1; 38 | remoteGlobalIDString = 33B21FBA1C9409C2002FBFBF; 39 | remoteInfo = RTCollectionViewGroup; 40 | }; 41 | /* End PBXContainerItemProxy section */ 42 | 43 | /* Begin PBXFileReference section */ 44 | 33B21FBB1C9409C2002FBFBF /* RTCollectionViewGroup.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RTCollectionViewGroup.app; sourceTree = BUILT_PRODUCTS_DIR; }; 45 | 33B21FBF1C9409C2002FBFBF /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 46 | 33B21FC11C9409C2002FBFBF /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 47 | 33B21FC21C9409C2002FBFBF /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 48 | 33B21FC41C9409C2002FBFBF /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 49 | 33B21FC51C9409C2002FBFBF /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 50 | 33B21FC81C9409C2002FBFBF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 51 | 33B21FCA1C9409C2002FBFBF /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 52 | 33B21FCD1C9409C2002FBFBF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 53 | 33B21FCF1C9409C2002FBFBF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 54 | 33B21FD41C9409C2002FBFBF /* RTCollectionViewGroupTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RTCollectionViewGroupTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 55 | 33B21FD81C9409C2002FBFBF /* RTCollectionViewGroupTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RTCollectionViewGroupTests.m; sourceTree = ""; }; 56 | 33B21FDA1C9409C2002FBFBF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 57 | 33B21FDF1C9409C2002FBFBF /* RTCollectionViewGroupUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RTCollectionViewGroupUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 58 | 33B21FE31C9409C2002FBFBF /* RTCollectionViewGroupUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RTCollectionViewGroupUITests.m; sourceTree = ""; }; 59 | 33B21FE51C9409C2002FBFBF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 60 | 33B21FF11C940A5D002FBFBF /* GroupCollectionCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GroupCollectionCell.h; sourceTree = ""; }; 61 | 33B21FF21C940A5D002FBFBF /* GroupCollectionCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GroupCollectionCell.m; sourceTree = ""; }; 62 | 33B21FF31C940A5D002FBFBF /* GroupCollectionCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = GroupCollectionCell.xib; sourceTree = ""; }; 63 | 33B21FF61C940B4A002FBFBF /* GroupSection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GroupSection.h; sourceTree = ""; }; 64 | 33B21FF71C940B4A002FBFBF /* GroupSection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GroupSection.m; sourceTree = ""; }; 65 | 33B21FF81C940B4A002FBFBF /* GroupSection.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = GroupSection.xib; sourceTree = ""; }; 66 | 33B21FFB1C940D7D002FBFBF /* btn_menu_normal@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "btn_menu_normal@2x.png"; sourceTree = ""; }; 67 | 33B21FFC1C940D7D002FBFBF /* btn_menu@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "btn_menu@2x.png"; sourceTree = ""; }; 68 | /* End PBXFileReference section */ 69 | 70 | /* Begin PBXFrameworksBuildPhase section */ 71 | 33B21FB81C9409C2002FBFBF /* Frameworks */ = { 72 | isa = PBXFrameworksBuildPhase; 73 | buildActionMask = 2147483647; 74 | files = ( 75 | ); 76 | runOnlyForDeploymentPostprocessing = 0; 77 | }; 78 | 33B21FD11C9409C2002FBFBF /* Frameworks */ = { 79 | isa = PBXFrameworksBuildPhase; 80 | buildActionMask = 2147483647; 81 | files = ( 82 | ); 83 | runOnlyForDeploymentPostprocessing = 0; 84 | }; 85 | 33B21FDC1C9409C2002FBFBF /* Frameworks */ = { 86 | isa = PBXFrameworksBuildPhase; 87 | buildActionMask = 2147483647; 88 | files = ( 89 | ); 90 | runOnlyForDeploymentPostprocessing = 0; 91 | }; 92 | /* End PBXFrameworksBuildPhase section */ 93 | 94 | /* Begin PBXGroup section */ 95 | 33B21FB21C9409C2002FBFBF = { 96 | isa = PBXGroup; 97 | children = ( 98 | 33B21FBD1C9409C2002FBFBF /* RTCollectionViewGroup */, 99 | 33B21FD71C9409C2002FBFBF /* RTCollectionViewGroupTests */, 100 | 33B21FE21C9409C2002FBFBF /* RTCollectionViewGroupUITests */, 101 | 33B21FBC1C9409C2002FBFBF /* Products */, 102 | ); 103 | sourceTree = ""; 104 | }; 105 | 33B21FBC1C9409C2002FBFBF /* Products */ = { 106 | isa = PBXGroup; 107 | children = ( 108 | 33B21FBB1C9409C2002FBFBF /* RTCollectionViewGroup.app */, 109 | 33B21FD41C9409C2002FBFBF /* RTCollectionViewGroupTests.xctest */, 110 | 33B21FDF1C9409C2002FBFBF /* RTCollectionViewGroupUITests.xctest */, 111 | ); 112 | name = Products; 113 | sourceTree = ""; 114 | }; 115 | 33B21FBD1C9409C2002FBFBF /* RTCollectionViewGroup */ = { 116 | isa = PBXGroup; 117 | children = ( 118 | 33B21FFB1C940D7D002FBFBF /* btn_menu_normal@2x.png */, 119 | 33B21FFC1C940D7D002FBFBF /* btn_menu@2x.png */, 120 | 33B21FC11C9409C2002FBFBF /* AppDelegate.h */, 121 | 33B21FC21C9409C2002FBFBF /* AppDelegate.m */, 122 | 33B21FC41C9409C2002FBFBF /* ViewController.h */, 123 | 33B21FC51C9409C2002FBFBF /* ViewController.m */, 124 | 33B21FF11C940A5D002FBFBF /* GroupCollectionCell.h */, 125 | 33B21FF21C940A5D002FBFBF /* GroupCollectionCell.m */, 126 | 33B21FF31C940A5D002FBFBF /* GroupCollectionCell.xib */, 127 | 33B21FF61C940B4A002FBFBF /* GroupSection.h */, 128 | 33B21FF71C940B4A002FBFBF /* GroupSection.m */, 129 | 33B21FF81C940B4A002FBFBF /* GroupSection.xib */, 130 | 33B21FC71C9409C2002FBFBF /* Main.storyboard */, 131 | 33B21FCA1C9409C2002FBFBF /* Assets.xcassets */, 132 | 33B21FCC1C9409C2002FBFBF /* LaunchScreen.storyboard */, 133 | 33B21FCF1C9409C2002FBFBF /* Info.plist */, 134 | 33B21FBE1C9409C2002FBFBF /* Supporting Files */, 135 | ); 136 | path = RTCollectionViewGroup; 137 | sourceTree = ""; 138 | }; 139 | 33B21FBE1C9409C2002FBFBF /* Supporting Files */ = { 140 | isa = PBXGroup; 141 | children = ( 142 | 33B21FBF1C9409C2002FBFBF /* main.m */, 143 | ); 144 | name = "Supporting Files"; 145 | sourceTree = ""; 146 | }; 147 | 33B21FD71C9409C2002FBFBF /* RTCollectionViewGroupTests */ = { 148 | isa = PBXGroup; 149 | children = ( 150 | 33B21FD81C9409C2002FBFBF /* RTCollectionViewGroupTests.m */, 151 | 33B21FDA1C9409C2002FBFBF /* Info.plist */, 152 | ); 153 | path = RTCollectionViewGroupTests; 154 | sourceTree = ""; 155 | }; 156 | 33B21FE21C9409C2002FBFBF /* RTCollectionViewGroupUITests */ = { 157 | isa = PBXGroup; 158 | children = ( 159 | 33B21FE31C9409C2002FBFBF /* RTCollectionViewGroupUITests.m */, 160 | 33B21FE51C9409C2002FBFBF /* Info.plist */, 161 | ); 162 | path = RTCollectionViewGroupUITests; 163 | sourceTree = ""; 164 | }; 165 | /* End PBXGroup section */ 166 | 167 | /* Begin PBXNativeTarget section */ 168 | 33B21FBA1C9409C2002FBFBF /* RTCollectionViewGroup */ = { 169 | isa = PBXNativeTarget; 170 | buildConfigurationList = 33B21FE81C9409C3002FBFBF /* Build configuration list for PBXNativeTarget "RTCollectionViewGroup" */; 171 | buildPhases = ( 172 | 33B21FB71C9409C2002FBFBF /* Sources */, 173 | 33B21FB81C9409C2002FBFBF /* Frameworks */, 174 | 33B21FB91C9409C2002FBFBF /* Resources */, 175 | ); 176 | buildRules = ( 177 | ); 178 | dependencies = ( 179 | ); 180 | name = RTCollectionViewGroup; 181 | productName = RTCollectionViewGroup; 182 | productReference = 33B21FBB1C9409C2002FBFBF /* RTCollectionViewGroup.app */; 183 | productType = "com.apple.product-type.application"; 184 | }; 185 | 33B21FD31C9409C2002FBFBF /* RTCollectionViewGroupTests */ = { 186 | isa = PBXNativeTarget; 187 | buildConfigurationList = 33B21FEB1C9409C3002FBFBF /* Build configuration list for PBXNativeTarget "RTCollectionViewGroupTests" */; 188 | buildPhases = ( 189 | 33B21FD01C9409C2002FBFBF /* Sources */, 190 | 33B21FD11C9409C2002FBFBF /* Frameworks */, 191 | 33B21FD21C9409C2002FBFBF /* Resources */, 192 | ); 193 | buildRules = ( 194 | ); 195 | dependencies = ( 196 | 33B21FD61C9409C2002FBFBF /* PBXTargetDependency */, 197 | ); 198 | name = RTCollectionViewGroupTests; 199 | productName = RTCollectionViewGroupTests; 200 | productReference = 33B21FD41C9409C2002FBFBF /* RTCollectionViewGroupTests.xctest */; 201 | productType = "com.apple.product-type.bundle.unit-test"; 202 | }; 203 | 33B21FDE1C9409C2002FBFBF /* RTCollectionViewGroupUITests */ = { 204 | isa = PBXNativeTarget; 205 | buildConfigurationList = 33B21FEE1C9409C3002FBFBF /* Build configuration list for PBXNativeTarget "RTCollectionViewGroupUITests" */; 206 | buildPhases = ( 207 | 33B21FDB1C9409C2002FBFBF /* Sources */, 208 | 33B21FDC1C9409C2002FBFBF /* Frameworks */, 209 | 33B21FDD1C9409C2002FBFBF /* Resources */, 210 | ); 211 | buildRules = ( 212 | ); 213 | dependencies = ( 214 | 33B21FE11C9409C2002FBFBF /* PBXTargetDependency */, 215 | ); 216 | name = RTCollectionViewGroupUITests; 217 | productName = RTCollectionViewGroupUITests; 218 | productReference = 33B21FDF1C9409C2002FBFBF /* RTCollectionViewGroupUITests.xctest */; 219 | productType = "com.apple.product-type.bundle.ui-testing"; 220 | }; 221 | /* End PBXNativeTarget section */ 222 | 223 | /* Begin PBXProject section */ 224 | 33B21FB31C9409C2002FBFBF /* Project object */ = { 225 | isa = PBXProject; 226 | attributes = { 227 | LastUpgradeCheck = 0720; 228 | ORGANIZATIONNAME = Rabbit; 229 | TargetAttributes = { 230 | 33B21FBA1C9409C2002FBFBF = { 231 | CreatedOnToolsVersion = 7.2.1; 232 | DevelopmentTeam = 84SCG89399; 233 | }; 234 | 33B21FD31C9409C2002FBFBF = { 235 | CreatedOnToolsVersion = 7.2.1; 236 | DevelopmentTeam = 84SCG89399; 237 | TestTargetID = 33B21FBA1C9409C2002FBFBF; 238 | }; 239 | 33B21FDE1C9409C2002FBFBF = { 240 | CreatedOnToolsVersion = 7.2.1; 241 | DevelopmentTeam = 84SCG89399; 242 | TestTargetID = 33B21FBA1C9409C2002FBFBF; 243 | }; 244 | }; 245 | }; 246 | buildConfigurationList = 33B21FB61C9409C2002FBFBF /* Build configuration list for PBXProject "RTCollectionViewGroup" */; 247 | compatibilityVersion = "Xcode 3.2"; 248 | developmentRegion = English; 249 | hasScannedForEncodings = 0; 250 | knownRegions = ( 251 | en, 252 | Base, 253 | ); 254 | mainGroup = 33B21FB21C9409C2002FBFBF; 255 | productRefGroup = 33B21FBC1C9409C2002FBFBF /* Products */; 256 | projectDirPath = ""; 257 | projectRoot = ""; 258 | targets = ( 259 | 33B21FBA1C9409C2002FBFBF /* RTCollectionViewGroup */, 260 | 33B21FD31C9409C2002FBFBF /* RTCollectionViewGroupTests */, 261 | 33B21FDE1C9409C2002FBFBF /* RTCollectionViewGroupUITests */, 262 | ); 263 | }; 264 | /* End PBXProject section */ 265 | 266 | /* Begin PBXResourcesBuildPhase section */ 267 | 33B21FB91C9409C2002FBFBF /* Resources */ = { 268 | isa = PBXResourcesBuildPhase; 269 | buildActionMask = 2147483647; 270 | files = ( 271 | 33B21FFA1C940B4A002FBFBF /* GroupSection.xib in Resources */, 272 | 33B21FFD1C940D7D002FBFBF /* btn_menu_normal@2x.png in Resources */, 273 | 33B21FCE1C9409C2002FBFBF /* LaunchScreen.storyboard in Resources */, 274 | 33B21FF51C940A5D002FBFBF /* GroupCollectionCell.xib in Resources */, 275 | 33B21FCB1C9409C2002FBFBF /* Assets.xcassets in Resources */, 276 | 33B21FFE1C940D7D002FBFBF /* btn_menu@2x.png in Resources */, 277 | 33B21FC91C9409C2002FBFBF /* Main.storyboard in Resources */, 278 | ); 279 | runOnlyForDeploymentPostprocessing = 0; 280 | }; 281 | 33B21FD21C9409C2002FBFBF /* Resources */ = { 282 | isa = PBXResourcesBuildPhase; 283 | buildActionMask = 2147483647; 284 | files = ( 285 | ); 286 | runOnlyForDeploymentPostprocessing = 0; 287 | }; 288 | 33B21FDD1C9409C2002FBFBF /* Resources */ = { 289 | isa = PBXResourcesBuildPhase; 290 | buildActionMask = 2147483647; 291 | files = ( 292 | ); 293 | runOnlyForDeploymentPostprocessing = 0; 294 | }; 295 | /* End PBXResourcesBuildPhase section */ 296 | 297 | /* Begin PBXSourcesBuildPhase section */ 298 | 33B21FB71C9409C2002FBFBF /* Sources */ = { 299 | isa = PBXSourcesBuildPhase; 300 | buildActionMask = 2147483647; 301 | files = ( 302 | 33B21FC61C9409C2002FBFBF /* ViewController.m in Sources */, 303 | 33B21FF41C940A5D002FBFBF /* GroupCollectionCell.m in Sources */, 304 | 33B21FC31C9409C2002FBFBF /* AppDelegate.m in Sources */, 305 | 33B21FC01C9409C2002FBFBF /* main.m in Sources */, 306 | 33B21FF91C940B4A002FBFBF /* GroupSection.m in Sources */, 307 | ); 308 | runOnlyForDeploymentPostprocessing = 0; 309 | }; 310 | 33B21FD01C9409C2002FBFBF /* Sources */ = { 311 | isa = PBXSourcesBuildPhase; 312 | buildActionMask = 2147483647; 313 | files = ( 314 | 33B21FD91C9409C2002FBFBF /* RTCollectionViewGroupTests.m in Sources */, 315 | ); 316 | runOnlyForDeploymentPostprocessing = 0; 317 | }; 318 | 33B21FDB1C9409C2002FBFBF /* Sources */ = { 319 | isa = PBXSourcesBuildPhase; 320 | buildActionMask = 2147483647; 321 | files = ( 322 | 33B21FE41C9409C2002FBFBF /* RTCollectionViewGroupUITests.m in Sources */, 323 | ); 324 | runOnlyForDeploymentPostprocessing = 0; 325 | }; 326 | /* End PBXSourcesBuildPhase section */ 327 | 328 | /* Begin PBXTargetDependency section */ 329 | 33B21FD61C9409C2002FBFBF /* PBXTargetDependency */ = { 330 | isa = PBXTargetDependency; 331 | target = 33B21FBA1C9409C2002FBFBF /* RTCollectionViewGroup */; 332 | targetProxy = 33B21FD51C9409C2002FBFBF /* PBXContainerItemProxy */; 333 | }; 334 | 33B21FE11C9409C2002FBFBF /* PBXTargetDependency */ = { 335 | isa = PBXTargetDependency; 336 | target = 33B21FBA1C9409C2002FBFBF /* RTCollectionViewGroup */; 337 | targetProxy = 33B21FE01C9409C2002FBFBF /* PBXContainerItemProxy */; 338 | }; 339 | /* End PBXTargetDependency section */ 340 | 341 | /* Begin PBXVariantGroup section */ 342 | 33B21FC71C9409C2002FBFBF /* Main.storyboard */ = { 343 | isa = PBXVariantGroup; 344 | children = ( 345 | 33B21FC81C9409C2002FBFBF /* Base */, 346 | ); 347 | name = Main.storyboard; 348 | sourceTree = ""; 349 | }; 350 | 33B21FCC1C9409C2002FBFBF /* LaunchScreen.storyboard */ = { 351 | isa = PBXVariantGroup; 352 | children = ( 353 | 33B21FCD1C9409C2002FBFBF /* Base */, 354 | ); 355 | name = LaunchScreen.storyboard; 356 | sourceTree = ""; 357 | }; 358 | /* End PBXVariantGroup section */ 359 | 360 | /* Begin XCBuildConfiguration section */ 361 | 33B21FE61C9409C3002FBFBF /* Debug */ = { 362 | isa = XCBuildConfiguration; 363 | buildSettings = { 364 | ALWAYS_SEARCH_USER_PATHS = NO; 365 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 366 | CLANG_CXX_LIBRARY = "libc++"; 367 | CLANG_ENABLE_MODULES = YES; 368 | CLANG_ENABLE_OBJC_ARC = YES; 369 | CLANG_WARN_BOOL_CONVERSION = YES; 370 | CLANG_WARN_CONSTANT_CONVERSION = YES; 371 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 372 | CLANG_WARN_EMPTY_BODY = YES; 373 | CLANG_WARN_ENUM_CONVERSION = YES; 374 | CLANG_WARN_INT_CONVERSION = YES; 375 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 376 | CLANG_WARN_UNREACHABLE_CODE = YES; 377 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 378 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 379 | COPY_PHASE_STRIP = NO; 380 | DEBUG_INFORMATION_FORMAT = dwarf; 381 | ENABLE_STRICT_OBJC_MSGSEND = YES; 382 | ENABLE_TESTABILITY = YES; 383 | GCC_C_LANGUAGE_STANDARD = gnu99; 384 | GCC_DYNAMIC_NO_PIC = NO; 385 | GCC_NO_COMMON_BLOCKS = YES; 386 | GCC_OPTIMIZATION_LEVEL = 0; 387 | GCC_PREPROCESSOR_DEFINITIONS = ( 388 | "DEBUG=1", 389 | "$(inherited)", 390 | ); 391 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 392 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 393 | GCC_WARN_UNDECLARED_SELECTOR = YES; 394 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 395 | GCC_WARN_UNUSED_FUNCTION = YES; 396 | GCC_WARN_UNUSED_VARIABLE = YES; 397 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 398 | MTL_ENABLE_DEBUG_INFO = YES; 399 | ONLY_ACTIVE_ARCH = YES; 400 | SDKROOT = iphoneos; 401 | }; 402 | name = Debug; 403 | }; 404 | 33B21FE71C9409C3002FBFBF /* Release */ = { 405 | isa = XCBuildConfiguration; 406 | buildSettings = { 407 | ALWAYS_SEARCH_USER_PATHS = NO; 408 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 409 | CLANG_CXX_LIBRARY = "libc++"; 410 | CLANG_ENABLE_MODULES = YES; 411 | CLANG_ENABLE_OBJC_ARC = YES; 412 | CLANG_WARN_BOOL_CONVERSION = YES; 413 | CLANG_WARN_CONSTANT_CONVERSION = YES; 414 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 415 | CLANG_WARN_EMPTY_BODY = YES; 416 | CLANG_WARN_ENUM_CONVERSION = YES; 417 | CLANG_WARN_INT_CONVERSION = YES; 418 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 419 | CLANG_WARN_UNREACHABLE_CODE = YES; 420 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 421 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 422 | COPY_PHASE_STRIP = NO; 423 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 424 | ENABLE_NS_ASSERTIONS = NO; 425 | ENABLE_STRICT_OBJC_MSGSEND = YES; 426 | GCC_C_LANGUAGE_STANDARD = gnu99; 427 | GCC_NO_COMMON_BLOCKS = YES; 428 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 429 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 430 | GCC_WARN_UNDECLARED_SELECTOR = YES; 431 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 432 | GCC_WARN_UNUSED_FUNCTION = YES; 433 | GCC_WARN_UNUSED_VARIABLE = YES; 434 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 435 | MTL_ENABLE_DEBUG_INFO = NO; 436 | SDKROOT = iphoneos; 437 | VALIDATE_PRODUCT = YES; 438 | }; 439 | name = Release; 440 | }; 441 | 33B21FE91C9409C3002FBFBF /* Debug */ = { 442 | isa = XCBuildConfiguration; 443 | buildSettings = { 444 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 445 | INFOPLIST_FILE = RTCollectionViewGroup/Info.plist; 446 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 447 | PRODUCT_BUNDLE_IDENTIFIER = com.Rabbit.RTCollectionViewGroup; 448 | PRODUCT_NAME = "$(TARGET_NAME)"; 449 | }; 450 | name = Debug; 451 | }; 452 | 33B21FEA1C9409C3002FBFBF /* Release */ = { 453 | isa = XCBuildConfiguration; 454 | buildSettings = { 455 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 456 | INFOPLIST_FILE = RTCollectionViewGroup/Info.plist; 457 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 458 | PRODUCT_BUNDLE_IDENTIFIER = com.Rabbit.RTCollectionViewGroup; 459 | PRODUCT_NAME = "$(TARGET_NAME)"; 460 | }; 461 | name = Release; 462 | }; 463 | 33B21FEC1C9409C3002FBFBF /* Debug */ = { 464 | isa = XCBuildConfiguration; 465 | buildSettings = { 466 | BUNDLE_LOADER = "$(TEST_HOST)"; 467 | INFOPLIST_FILE = RTCollectionViewGroupTests/Info.plist; 468 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 469 | PRODUCT_BUNDLE_IDENTIFIER = com.Rabbit.RTCollectionViewGroupTests; 470 | PRODUCT_NAME = "$(TARGET_NAME)"; 471 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/RTCollectionViewGroup.app/RTCollectionViewGroup"; 472 | }; 473 | name = Debug; 474 | }; 475 | 33B21FED1C9409C3002FBFBF /* Release */ = { 476 | isa = XCBuildConfiguration; 477 | buildSettings = { 478 | BUNDLE_LOADER = "$(TEST_HOST)"; 479 | INFOPLIST_FILE = RTCollectionViewGroupTests/Info.plist; 480 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 481 | PRODUCT_BUNDLE_IDENTIFIER = com.Rabbit.RTCollectionViewGroupTests; 482 | PRODUCT_NAME = "$(TARGET_NAME)"; 483 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/RTCollectionViewGroup.app/RTCollectionViewGroup"; 484 | }; 485 | name = Release; 486 | }; 487 | 33B21FEF1C9409C3002FBFBF /* Debug */ = { 488 | isa = XCBuildConfiguration; 489 | buildSettings = { 490 | INFOPLIST_FILE = RTCollectionViewGroupUITests/Info.plist; 491 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 492 | PRODUCT_BUNDLE_IDENTIFIER = com.Rabbit.RTCollectionViewGroupUITests; 493 | PRODUCT_NAME = "$(TARGET_NAME)"; 494 | TEST_TARGET_NAME = RTCollectionViewGroup; 495 | USES_XCTRUNNER = YES; 496 | }; 497 | name = Debug; 498 | }; 499 | 33B21FF01C9409C3002FBFBF /* Release */ = { 500 | isa = XCBuildConfiguration; 501 | buildSettings = { 502 | INFOPLIST_FILE = RTCollectionViewGroupUITests/Info.plist; 503 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 504 | PRODUCT_BUNDLE_IDENTIFIER = com.Rabbit.RTCollectionViewGroupUITests; 505 | PRODUCT_NAME = "$(TARGET_NAME)"; 506 | TEST_TARGET_NAME = RTCollectionViewGroup; 507 | USES_XCTRUNNER = YES; 508 | }; 509 | name = Release; 510 | }; 511 | /* End XCBuildConfiguration section */ 512 | 513 | /* Begin XCConfigurationList section */ 514 | 33B21FB61C9409C2002FBFBF /* Build configuration list for PBXProject "RTCollectionViewGroup" */ = { 515 | isa = XCConfigurationList; 516 | buildConfigurations = ( 517 | 33B21FE61C9409C3002FBFBF /* Debug */, 518 | 33B21FE71C9409C3002FBFBF /* Release */, 519 | ); 520 | defaultConfigurationIsVisible = 0; 521 | defaultConfigurationName = Release; 522 | }; 523 | 33B21FE81C9409C3002FBFBF /* Build configuration list for PBXNativeTarget "RTCollectionViewGroup" */ = { 524 | isa = XCConfigurationList; 525 | buildConfigurations = ( 526 | 33B21FE91C9409C3002FBFBF /* Debug */, 527 | 33B21FEA1C9409C3002FBFBF /* Release */, 528 | ); 529 | defaultConfigurationIsVisible = 0; 530 | }; 531 | 33B21FEB1C9409C3002FBFBF /* Build configuration list for PBXNativeTarget "RTCollectionViewGroupTests" */ = { 532 | isa = XCConfigurationList; 533 | buildConfigurations = ( 534 | 33B21FEC1C9409C3002FBFBF /* Debug */, 535 | 33B21FED1C9409C3002FBFBF /* Release */, 536 | ); 537 | defaultConfigurationIsVisible = 0; 538 | }; 539 | 33B21FEE1C9409C3002FBFBF /* Build configuration list for PBXNativeTarget "RTCollectionViewGroupUITests" */ = { 540 | isa = XCConfigurationList; 541 | buildConfigurations = ( 542 | 33B21FEF1C9409C3002FBFBF /* Debug */, 543 | 33B21FF01C9409C3002FBFBF /* Release */, 544 | ); 545 | defaultConfigurationIsVisible = 0; 546 | }; 547 | /* End XCConfigurationList section */ 548 | }; 549 | rootObject = 33B21FB31C9409C2002FBFBF /* Project object */; 550 | } 551 | -------------------------------------------------------------------------------- /RTCollectionViewGroup/RTCollectionViewGroup.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /RTCollectionViewGroup/RTCollectionViewGroup.xcodeproj/project.xcworkspace/xcuserdata/Rabbit.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeRabbitYu/RTCollectionViewGroup/e4ecb6a139780ecff7ff61d1bc7923f8798929a9/RTCollectionViewGroup/RTCollectionViewGroup.xcodeproj/project.xcworkspace/xcuserdata/Rabbit.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /RTCollectionViewGroup/RTCollectionViewGroup.xcodeproj/xcuserdata/Rabbit.xcuserdatad/xcschemes/RTCollectionViewGroup.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 43 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 74 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 95 | 101 | 102 | 103 | 104 | 106 | 107 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /RTCollectionViewGroup/RTCollectionViewGroup.xcodeproj/xcuserdata/Rabbit.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | RTCollectionViewGroup.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 33B21FBA1C9409C2002FBFBF 16 | 17 | primary 18 | 19 | 20 | 33B21FD31C9409C2002FBFBF 21 | 22 | primary 23 | 24 | 25 | 33B21FDE1C9409C2002FBFBF 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /RTCollectionViewGroup/RTCollectionViewGroup/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // RTCollectionViewGroup 4 | // 5 | // Created by Rabbit on 16/3/12. 6 | // Copyright © 2016年 Rabbit. 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 | -------------------------------------------------------------------------------- /RTCollectionViewGroup/RTCollectionViewGroup/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // RTCollectionViewGroup 4 | // 5 | // Created by Rabbit on 16/3/12. 6 | // Copyright © 2016年 Rabbit. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /RTCollectionViewGroup/RTCollectionViewGroup/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 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /RTCollectionViewGroup/RTCollectionViewGroup/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 | -------------------------------------------------------------------------------- /RTCollectionViewGroup/RTCollectionViewGroup/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 | -------------------------------------------------------------------------------- /RTCollectionViewGroup/RTCollectionViewGroup/GroupCollectionCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // GroupCollectionCell.h 3 | // RTCollectionViewGroup 4 | // 5 | // Created by Rabbit on 16/3/12. 6 | // Copyright © 2016年 Rabbit. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface GroupCollectionCell : UICollectionViewCell 12 | @property (weak, nonatomic) IBOutlet UIImageView *iconImage; 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /RTCollectionViewGroup/RTCollectionViewGroup/GroupCollectionCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // GroupCollectionCell.m 3 | // RTCollectionViewGroup 4 | // 5 | // Created by Rabbit on 16/3/12. 6 | // Copyright © 2016年 Rabbit. All rights reserved. 7 | // 8 | 9 | #import "GroupCollectionCell.h" 10 | 11 | @implementation GroupCollectionCell 12 | 13 | - (void)awakeFromNib { 14 | // Initialization code 15 | } 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /RTCollectionViewGroup/RTCollectionViewGroup/GroupCollectionCell.xib: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /RTCollectionViewGroup/RTCollectionViewGroup/GroupSection.h: -------------------------------------------------------------------------------- 1 | // 2 | // GroupSection.h 3 | // RTCollectionViewGroup 4 | // 5 | // Created by Rabbit on 16/3/12. 6 | // Copyright © 2016年 Rabbit. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface GroupSection : UICollectionReusableView 12 | @property (weak, nonatomic) IBOutlet UIButton *sectionBtn; 13 | @property (weak, nonatomic) IBOutlet UILabel *sectionTitle; 14 | @property (weak, nonatomic) IBOutlet UIImageView *iconImage; 15 | @property (weak, nonatomic) IBOutlet NSLayoutConstraint *imgWidth; 16 | @property (weak, nonatomic) IBOutlet NSLayoutConstraint *imgHeight; 17 | @end 18 | -------------------------------------------------------------------------------- /RTCollectionViewGroup/RTCollectionViewGroup/GroupSection.m: -------------------------------------------------------------------------------- 1 | // 2 | // GroupSection.m 3 | // RTCollectionViewGroup 4 | // 5 | // Created by Rabbit on 16/3/12. 6 | // Copyright © 2016年 Rabbit. All rights reserved. 7 | // 8 | 9 | #import "GroupSection.h" 10 | 11 | @implementation GroupSection 12 | 13 | - (void)awakeFromNib { 14 | // Initialization code 15 | } 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /RTCollectionViewGroup/RTCollectionViewGroup/GroupSection.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 37 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /RTCollectionViewGroup/RTCollectionViewGroup/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 | 40 | 41 | -------------------------------------------------------------------------------- /RTCollectionViewGroup/RTCollectionViewGroup/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // RTCollectionViewGroup 4 | // 5 | // Created by Rabbit on 16/3/12. 6 | // Copyright © 2016年 Rabbit. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /RTCollectionViewGroup/RTCollectionViewGroup/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // RTCollectionViewGroup 4 | // 5 | // Created by Rabbit on 16/3/12. 6 | // Copyright © 2016年 Rabbit. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "GroupCollectionCell.h" 11 | #import "GroupSection.h" 12 | 13 | #define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width) 14 | #define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height) 15 | 16 | @interface ViewController () 17 | @property (nonatomic, strong) UICollectionView *collectionView; 18 | //内容数组 19 | @property (nonatomic, strong) NSMutableArray *dataArray; 20 | //标题数组 21 | @property (nonatomic, strong) NSMutableArray *sectionArray; 22 | 23 | @property (nonatomic, strong) NSMutableArray *stateArray; 24 | @end 25 | 26 | @implementation ViewController 27 | 28 | - (void)viewDidLoad { 29 | [super viewDidLoad]; 30 | 31 | 32 | 33 | //创建CollectionView布局类的对象,UICollectionViewFlowLayout有水平和垂直两种布局方式,如果你需要做复杂的而已可以继承UICollectionViewFlowLayout创建你自己的布局类 34 | UICollectionViewFlowLayout *flow = [[UICollectionViewFlowLayout alloc]init]; 35 | //指定布局方式为垂直 36 | flow.scrollDirection = UICollectionViewScrollDirectionVertical; 37 | flow.minimumLineSpacing = 10;//最小行间距(当垂直布局时是行间距,当水平布局时可以理解为列间距) 38 | flow.minimumInteritemSpacing = 10;//两个单元格之间的最小间距 39 | 40 | //创建CollectionView并指定布局对象 41 | _collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) collectionViewLayout:flow]; 42 | _collectionView.backgroundColor = [UIColor colorWithRed:239/255.0f green:239/255.0f blue:239/255.0f alpha:1.0]; 43 | _collectionView.dataSource = self; 44 | _collectionView.delegate = self; 45 | [self.view addSubview:_collectionView]; 46 | 47 | //注册用xib定制的cell,各参数的含义同UITableViewCell的注册 48 | [_collectionView registerNib:[UINib nibWithNibName:@"GroupCollectionCell" bundle:nil] forCellWithReuseIdentifier:@"GroupCellID"]; 49 | 50 | //注册用xib定制的分组脚 51 | //参数二:用来区分是分组头还是分组脚 52 | [_collectionView registerNib:[UINib nibWithNibName:@"GroupSection" bundle:nil] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"GroupSectionID"]; 53 | 54 | NSArray *one = @[@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9"]; 55 | NSArray *two = @[@"1",@"2",@"3",@"4",@"5",@"6"]; 56 | // _sectionArray = [NSMutableArray arrayWithObjects:[NSString stringWithFormat:@"关闭(%ld)",one.count],[NSString stringWithFormat:@"关闭(%ld)",two.count], nil]; 57 | _sectionArray = [NSMutableArray arrayWithObjects:@"关闭",@"关闭", nil]; 58 | 59 | _dataArray = [NSMutableArray arrayWithObjects:one,two, nil]; 60 | 61 | _stateArray = [NSMutableArray array]; 62 | 63 | for (int i = 0; i < _dataArray.count; i++) 64 | { 65 | //所有的分区都是闭合 66 | [_stateArray addObject:@"0"]; 67 | } 68 | } 69 | 70 | //协议的方法,用于返回section的个数 71 | - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{ 72 | return _dataArray.count; 73 | } 74 | 75 | //协议中的方法,用于返回分区中的单元格个数 76 | - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section 77 | { 78 | if ([_stateArray[section] isEqualToString:@"1"]) { 79 | //如果是打开状态 80 | NSArray *arr = [_dataArray objectAtIndex:section]; 81 | return arr.count; 82 | } 83 | else{ 84 | return 0; 85 | } 86 | } 87 | 88 | - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ 89 | //UICollectionViewCell里的属性非常少,实际做项目的时候几乎必须以其为基类定制自己的Cell 90 | GroupCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"GroupCellID" forIndexPath:indexPath]; 91 | cell.backgroundColor = [UIColor greenColor]; 92 | return cell; 93 | } 94 | 95 | //协议中的方法,用于返回单元格的大小 96 | - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath 97 | { 98 | return CGSizeMake(SCREEN_WIDTH / 4 - 10, SCREEN_WIDTH / 4); 99 | } 100 | 101 | //协议中的方法,用于返回整个CollectionView上、左、下、右距四边的间距 102 | - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section 103 | { 104 | //上、左、下、右的边距 105 | return UIEdgeInsetsMake(0, 5, 0, 5); 106 | } 107 | 108 | //协议中的方法,用来返回分组头的大小。如果不实现这个方法,- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath将不会被调用 109 | - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section 110 | { 111 | //宽度随便定,系统会自动取collectionView的宽度 112 | //高度为分组头的高度 113 | return CGSizeMake(0, 44); 114 | } 115 | 116 | 117 | //协议中的方法,用来返回CollectionView的分组头或者分组脚 118 | //参数二:用来区分是分组头还是分组脚 119 | - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath 120 | { 121 | //重用分组头,因为前边注册过,所以重用一定会成功 122 | //参数一:用来区分是分组头还是分组脚 123 | //参数二:注册分组头时指定的ID 124 | GroupSection *header = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"GroupSectionID" forIndexPath:indexPath]; 125 | header.sectionTitle.text = _sectionArray[indexPath.section]; 126 | [header.sectionBtn addTarget:self action:@selector(buttonClick:) forControlEvents:(UIControlEventTouchUpInside)]; 127 | header.sectionBtn.tag = indexPath.section + 1; 128 | // header.iconImage.backgroundColor = [UIColor purpleColor]; 129 | 130 | if ([_stateArray[indexPath.section] isEqualToString:@"0"]) { 131 | // header.iconImage.backgroundColor = [UIColor redColor]; 132 | header.iconImage.image = [UIImage imageNamed:@"btn_menu_normal"]; 133 | header.imgHeight.constant = 12.0f; 134 | header.imgWidth.constant = 7.0f; 135 | header.sectionTitle.text = @"关闭"; 136 | 137 | } 138 | else if ([_stateArray[indexPath.section] isEqualToString:@"1"]){ 139 | header.iconImage.image = [UIImage imageNamed:@"btn_menu@2x.png"]; 140 | header.imgHeight.constant = 7.0f; 141 | header.imgWidth.constant = 12.0f; 142 | header.sectionTitle.text = @"打开"; 143 | 144 | } 145 | return header; 146 | } 147 | 148 | - (void)buttonClick:(UIButton *)sender//headButton点击 149 | { 150 | //判断状态值 151 | if ([_stateArray[sender.tag - 1] isEqualToString:@"1"]){ 152 | //修改 153 | [_stateArray replaceObjectAtIndex:sender.tag - 1 withObject:@"0"]; 154 | }else{ 155 | [_stateArray replaceObjectAtIndex:sender.tag - 1 withObject:@"1"]; 156 | } 157 | [_collectionView reloadSections:[NSIndexSet indexSetWithIndex:sender.tag-1]]; 158 | 159 | 160 | } 161 | 162 | @end 163 | -------------------------------------------------------------------------------- /RTCollectionViewGroup/RTCollectionViewGroup/btn_menu@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeRabbitYu/RTCollectionViewGroup/e4ecb6a139780ecff7ff61d1bc7923f8798929a9/RTCollectionViewGroup/RTCollectionViewGroup/btn_menu@2x.png -------------------------------------------------------------------------------- /RTCollectionViewGroup/RTCollectionViewGroup/btn_menu_normal@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeRabbitYu/RTCollectionViewGroup/e4ecb6a139780ecff7ff61d1bc7923f8798929a9/RTCollectionViewGroup/RTCollectionViewGroup/btn_menu_normal@2x.png -------------------------------------------------------------------------------- /RTCollectionViewGroup/RTCollectionViewGroup/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // RTCollectionViewGroup 4 | // 5 | // Created by Rabbit on 16/3/12. 6 | // Copyright © 2016年 Rabbit. 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 | -------------------------------------------------------------------------------- /RTCollectionViewGroup/RTCollectionViewGroupTests/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 | -------------------------------------------------------------------------------- /RTCollectionViewGroup/RTCollectionViewGroupTests/RTCollectionViewGroupTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // RTCollectionViewGroupTests.m 3 | // RTCollectionViewGroupTests 4 | // 5 | // Created by Rabbit on 16/3/12. 6 | // Copyright © 2016年 Rabbit. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface RTCollectionViewGroupTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation RTCollectionViewGroupTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /RTCollectionViewGroup/RTCollectionViewGroupUITests/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 | -------------------------------------------------------------------------------- /RTCollectionViewGroup/RTCollectionViewGroupUITests/RTCollectionViewGroupUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // RTCollectionViewGroupUITests.m 3 | // RTCollectionViewGroupUITests 4 | // 5 | // Created by Rabbit on 16/3/12. 6 | // Copyright © 2016年 Rabbit. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface RTCollectionViewGroupUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation RTCollectionViewGroupUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | --------------------------------------------------------------------------------