├── .DS_Store ├── README.md ├── ScrollPageControllDemo ├── .DS_Store ├── ScrollPageControllDemo.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── wuchuanliang.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── wuchuanliang.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ ├── ScrollPageControllDemo.xcscheme │ │ └── xcschememanagement.plist ├── ScrollPageControllDemo │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Info.plist │ ├── SLMoreLineViewController.h │ ├── SLMoreLineViewController.m │ ├── SLOneLineViewController.h │ ├── SLOneLineViewController.m │ ├── SLScrollViewMoreLineItem │ │ ├── SLScrollViewHorizontalItem.h │ │ └── SLScrollViewHorizontalItem.m │ ├── SLScrollViewOneLineItem │ │ ├── SLScrollViewOneLineItem.h │ │ └── SLScrollViewOneLineItem.m │ ├── ViewController.h │ ├── ViewController.m │ └── main.m ├── ScrollPageControllDemoTests │ ├── Info.plist │ └── ScrollPageControllDemoTests.m └── ScrollPageControllDemoUITests │ ├── Info.plist │ └── ScrollPageControllDemoUITests.m └── image ├── demo.gif ├── horizontal.gif └── vertical.gif /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shanlianging/ScrollPageControll/67b5128702d06d1e5d4b66edfbc612e8da02e384/.DS_Store -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ScrollPageControll 2 | 一个横向和竖向排布的视图 3 | 4 | 5 | ## 介绍 6 | > * 此demo能够实现横向和纵向排序 7 | > * 具有点击功能 8 | > * 方便实用 9 | 10 | ``` 11 | @protocol SLScrollViewHorizontalItemDelegate 12 | 13 | @required; 14 | 15 | /** 16 | item的个数 17 | 18 | @param view 视图 19 | @return item的个数 20 | */ 21 | - (NSInteger)numberOfItemsInView:(UIView *)view; 22 | 23 | 24 | /** 25 | item视图 26 | 27 | @param view 视图 28 | @param index item的位置 29 | @return item视图 30 | */ 31 | - (UIView *)itemForView:(UIView *)view index:(NSInteger)index; 32 | 33 | @optional 34 | 35 | /** 36 | 几行 37 | 38 | @param view 视图 39 | @return 行数 40 | */ 41 | - (NSInteger)lineNumberOfItemsInView:(UIView *)view; 42 | 43 | /** 44 | 几列 45 | 46 | @param view 视图 47 | @return 列数 48 | */ 49 | - (NSInteger)columnNumberOfItemsInView:(UIView *)view; 50 | 51 | /** 52 | item边缘距离 53 | 54 | @param view 视图 55 | @return item的边缘距离 56 | */ 57 | - (UIEdgeInsets)edgeInsetsOfItemsInView:(UIView *)view; 58 | 59 | /** 60 | item视图之间的行高 61 | 62 | @param view 视图 63 | @return 行高 64 | */ 65 | - (CGFloat)lineSpaceOfItemsInView:(UIView *)view; 66 | 67 | /** 68 | item视图之间的列宽 69 | 70 | @param view 视图 71 | @return 列宽 72 | */ 73 | - (CGFloat)columnSpaceOfItemsInView:(UIView *)view; 74 | 75 | /** 76 | 选中的item 77 | 78 | @param item 选中的item视图 79 | @param index item的下标 80 | */ 81 | - (void)item:(UIView *)item didSelectItemAtIndex:(NSInteger)index; 82 | 83 | 84 | /** 85 | 排布方向 86 | 87 | @param view 视图 88 | @return 方向 89 | */ 90 | - (SLDistributionDirection)distributionDirectionAtView:(UIView *)view; 91 | 92 | ``` 93 | 94 | 95 | ![横向排布][1] 96 | 97 | ![纵向排布][2] 98 | 99 | 100 | [1]: https://github.com/shanlianging/ScrollPageControll/blob/master/image/horizontal.gif?raw=true 101 | [2]: https://github.com/shanlianging/ScrollPageControll/blob/master/image/vertical.gif?raw=true 102 | -------------------------------------------------------------------------------- /ScrollPageControllDemo/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shanlianging/ScrollPageControll/67b5128702d06d1e5d4b66edfbc612e8da02e384/ScrollPageControllDemo/.DS_Store -------------------------------------------------------------------------------- /ScrollPageControllDemo/ScrollPageControllDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 7A008C4D1F66D4A300A7B79C /* SLScrollViewOneLineItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 7A008C4C1F66D4A300A7B79C /* SLScrollViewOneLineItem.m */; }; 11 | 7A008C501F66D62F00A7B79C /* SLOneLineViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7A008C4F1F66D62F00A7B79C /* SLOneLineViewController.m */; }; 12 | 7A008C531F66D63C00A7B79C /* SLMoreLineViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7A008C521F66D63C00A7B79C /* SLMoreLineViewController.m */; }; 13 | 7A008C571F66D67E00A7B79C /* SLScrollViewHorizontalItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 7A008C561F66D67E00A7B79C /* SLScrollViewHorizontalItem.m */; }; 14 | 7A4A73A71F44820400F16956 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 7A4A73A61F44820400F16956 /* main.m */; }; 15 | 7A4A73AA1F44820400F16956 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7A4A73A91F44820400F16956 /* AppDelegate.m */; }; 16 | 7A4A73AD1F44820400F16956 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7A4A73AC1F44820400F16956 /* ViewController.m */; }; 17 | 7A4A73B01F44820400F16956 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7A4A73AE1F44820400F16956 /* Main.storyboard */; }; 18 | 7A4A73B21F44820400F16956 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7A4A73B11F44820400F16956 /* Assets.xcassets */; }; 19 | 7A4A73B51F44820400F16956 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7A4A73B31F44820400F16956 /* LaunchScreen.storyboard */; }; 20 | 7A4A73C01F44820500F16956 /* ScrollPageControllDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7A4A73BF1F44820500F16956 /* ScrollPageControllDemoTests.m */; }; 21 | 7A4A73CB1F44820500F16956 /* ScrollPageControllDemoUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7A4A73CA1F44820500F16956 /* ScrollPageControllDemoUITests.m */; }; 22 | /* End PBXBuildFile section */ 23 | 24 | /* Begin PBXContainerItemProxy section */ 25 | 7A4A73BC1F44820500F16956 /* PBXContainerItemProxy */ = { 26 | isa = PBXContainerItemProxy; 27 | containerPortal = 7A4A739A1F44820400F16956 /* Project object */; 28 | proxyType = 1; 29 | remoteGlobalIDString = 7A4A73A11F44820400F16956; 30 | remoteInfo = ScrollPageControllDemo; 31 | }; 32 | 7A4A73C71F44820500F16956 /* PBXContainerItemProxy */ = { 33 | isa = PBXContainerItemProxy; 34 | containerPortal = 7A4A739A1F44820400F16956 /* Project object */; 35 | proxyType = 1; 36 | remoteGlobalIDString = 7A4A73A11F44820400F16956; 37 | remoteInfo = ScrollPageControllDemo; 38 | }; 39 | /* End PBXContainerItemProxy section */ 40 | 41 | /* Begin PBXFileReference section */ 42 | 7A008C4B1F66D4A300A7B79C /* SLScrollViewOneLineItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLScrollViewOneLineItem.h; sourceTree = ""; }; 43 | 7A008C4C1F66D4A300A7B79C /* SLScrollViewOneLineItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLScrollViewOneLineItem.m; sourceTree = ""; }; 44 | 7A008C4E1F66D62F00A7B79C /* SLOneLineViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLOneLineViewController.h; sourceTree = ""; }; 45 | 7A008C4F1F66D62F00A7B79C /* SLOneLineViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLOneLineViewController.m; sourceTree = ""; }; 46 | 7A008C511F66D63C00A7B79C /* SLMoreLineViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLMoreLineViewController.h; sourceTree = ""; }; 47 | 7A008C521F66D63C00A7B79C /* SLMoreLineViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLMoreLineViewController.m; sourceTree = ""; }; 48 | 7A008C551F66D67E00A7B79C /* SLScrollViewHorizontalItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLScrollViewHorizontalItem.h; sourceTree = ""; }; 49 | 7A008C561F66D67E00A7B79C /* SLScrollViewHorizontalItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLScrollViewHorizontalItem.m; sourceTree = ""; }; 50 | 7A4A73A21F44820400F16956 /* ScrollPageControllDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ScrollPageControllDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 51 | 7A4A73A61F44820400F16956 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 52 | 7A4A73A81F44820400F16956 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 53 | 7A4A73A91F44820400F16956 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 54 | 7A4A73AB1F44820400F16956 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 55 | 7A4A73AC1F44820400F16956 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 56 | 7A4A73AF1F44820400F16956 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 57 | 7A4A73B11F44820400F16956 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 58 | 7A4A73B41F44820400F16956 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 59 | 7A4A73B61F44820400F16956 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 60 | 7A4A73BB1F44820500F16956 /* ScrollPageControllDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ScrollPageControllDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 61 | 7A4A73BF1F44820500F16956 /* ScrollPageControllDemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ScrollPageControllDemoTests.m; sourceTree = ""; }; 62 | 7A4A73C11F44820500F16956 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 63 | 7A4A73C61F44820500F16956 /* ScrollPageControllDemoUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ScrollPageControllDemoUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 64 | 7A4A73CA1F44820500F16956 /* ScrollPageControllDemoUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ScrollPageControllDemoUITests.m; sourceTree = ""; }; 65 | 7A4A73CC1F44820500F16956 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 66 | /* End PBXFileReference section */ 67 | 68 | /* Begin PBXFrameworksBuildPhase section */ 69 | 7A4A739F1F44820400F16956 /* Frameworks */ = { 70 | isa = PBXFrameworksBuildPhase; 71 | buildActionMask = 2147483647; 72 | files = ( 73 | ); 74 | runOnlyForDeploymentPostprocessing = 0; 75 | }; 76 | 7A4A73B81F44820500F16956 /* Frameworks */ = { 77 | isa = PBXFrameworksBuildPhase; 78 | buildActionMask = 2147483647; 79 | files = ( 80 | ); 81 | runOnlyForDeploymentPostprocessing = 0; 82 | }; 83 | 7A4A73C31F44820500F16956 /* Frameworks */ = { 84 | isa = PBXFrameworksBuildPhase; 85 | buildActionMask = 2147483647; 86 | files = ( 87 | ); 88 | runOnlyForDeploymentPostprocessing = 0; 89 | }; 90 | /* End PBXFrameworksBuildPhase section */ 91 | 92 | /* Begin PBXGroup section */ 93 | 7A008C4A1F66D4A300A7B79C /* SLScrollViewOneLineItem */ = { 94 | isa = PBXGroup; 95 | children = ( 96 | 7A008C4B1F66D4A300A7B79C /* SLScrollViewOneLineItem.h */, 97 | 7A008C4C1F66D4A300A7B79C /* SLScrollViewOneLineItem.m */, 98 | ); 99 | path = SLScrollViewOneLineItem; 100 | sourceTree = ""; 101 | }; 102 | 7A008C541F66D67E00A7B79C /* SLScrollViewMoreLineItem */ = { 103 | isa = PBXGroup; 104 | children = ( 105 | 7A008C551F66D67E00A7B79C /* SLScrollViewHorizontalItem.h */, 106 | 7A008C561F66D67E00A7B79C /* SLScrollViewHorizontalItem.m */, 107 | ); 108 | path = SLScrollViewMoreLineItem; 109 | sourceTree = ""; 110 | }; 111 | 7A4A73991F44820400F16956 = { 112 | isa = PBXGroup; 113 | children = ( 114 | 7A4A73A41F44820400F16956 /* ScrollPageControllDemo */, 115 | 7A4A73BE1F44820500F16956 /* ScrollPageControllDemoTests */, 116 | 7A4A73C91F44820500F16956 /* ScrollPageControllDemoUITests */, 117 | 7A4A73A31F44820400F16956 /* Products */, 118 | ); 119 | sourceTree = ""; 120 | }; 121 | 7A4A73A31F44820400F16956 /* Products */ = { 122 | isa = PBXGroup; 123 | children = ( 124 | 7A4A73A21F44820400F16956 /* ScrollPageControllDemo.app */, 125 | 7A4A73BB1F44820500F16956 /* ScrollPageControllDemoTests.xctest */, 126 | 7A4A73C61F44820500F16956 /* ScrollPageControllDemoUITests.xctest */, 127 | ); 128 | name = Products; 129 | sourceTree = ""; 130 | }; 131 | 7A4A73A41F44820400F16956 /* ScrollPageControllDemo */ = { 132 | isa = PBXGroup; 133 | children = ( 134 | 7A008C541F66D67E00A7B79C /* SLScrollViewMoreLineItem */, 135 | 7A008C4A1F66D4A300A7B79C /* SLScrollViewOneLineItem */, 136 | 7A4A73A81F44820400F16956 /* AppDelegate.h */, 137 | 7A4A73A91F44820400F16956 /* AppDelegate.m */, 138 | 7A4A73AB1F44820400F16956 /* ViewController.h */, 139 | 7A4A73AC1F44820400F16956 /* ViewController.m */, 140 | 7A008C4E1F66D62F00A7B79C /* SLOneLineViewController.h */, 141 | 7A008C4F1F66D62F00A7B79C /* SLOneLineViewController.m */, 142 | 7A008C511F66D63C00A7B79C /* SLMoreLineViewController.h */, 143 | 7A008C521F66D63C00A7B79C /* SLMoreLineViewController.m */, 144 | 7A4A73AE1F44820400F16956 /* Main.storyboard */, 145 | 7A4A73B11F44820400F16956 /* Assets.xcassets */, 146 | 7A4A73B31F44820400F16956 /* LaunchScreen.storyboard */, 147 | 7A4A73B61F44820400F16956 /* Info.plist */, 148 | 7A4A73A51F44820400F16956 /* Supporting Files */, 149 | ); 150 | path = ScrollPageControllDemo; 151 | sourceTree = ""; 152 | }; 153 | 7A4A73A51F44820400F16956 /* Supporting Files */ = { 154 | isa = PBXGroup; 155 | children = ( 156 | 7A4A73A61F44820400F16956 /* main.m */, 157 | ); 158 | name = "Supporting Files"; 159 | sourceTree = ""; 160 | }; 161 | 7A4A73BE1F44820500F16956 /* ScrollPageControllDemoTests */ = { 162 | isa = PBXGroup; 163 | children = ( 164 | 7A4A73BF1F44820500F16956 /* ScrollPageControllDemoTests.m */, 165 | 7A4A73C11F44820500F16956 /* Info.plist */, 166 | ); 167 | path = ScrollPageControllDemoTests; 168 | sourceTree = ""; 169 | }; 170 | 7A4A73C91F44820500F16956 /* ScrollPageControllDemoUITests */ = { 171 | isa = PBXGroup; 172 | children = ( 173 | 7A4A73CA1F44820500F16956 /* ScrollPageControllDemoUITests.m */, 174 | 7A4A73CC1F44820500F16956 /* Info.plist */, 175 | ); 176 | path = ScrollPageControllDemoUITests; 177 | sourceTree = ""; 178 | }; 179 | /* End PBXGroup section */ 180 | 181 | /* Begin PBXNativeTarget section */ 182 | 7A4A73A11F44820400F16956 /* ScrollPageControllDemo */ = { 183 | isa = PBXNativeTarget; 184 | buildConfigurationList = 7A4A73CF1F44820500F16956 /* Build configuration list for PBXNativeTarget "ScrollPageControllDemo" */; 185 | buildPhases = ( 186 | 7A4A739E1F44820400F16956 /* Sources */, 187 | 7A4A739F1F44820400F16956 /* Frameworks */, 188 | 7A4A73A01F44820400F16956 /* Resources */, 189 | ); 190 | buildRules = ( 191 | ); 192 | dependencies = ( 193 | ); 194 | name = ScrollPageControllDemo; 195 | productName = ScrollPageControllDemo; 196 | productReference = 7A4A73A21F44820400F16956 /* ScrollPageControllDemo.app */; 197 | productType = "com.apple.product-type.application"; 198 | }; 199 | 7A4A73BA1F44820500F16956 /* ScrollPageControllDemoTests */ = { 200 | isa = PBXNativeTarget; 201 | buildConfigurationList = 7A4A73D21F44820500F16956 /* Build configuration list for PBXNativeTarget "ScrollPageControllDemoTests" */; 202 | buildPhases = ( 203 | 7A4A73B71F44820500F16956 /* Sources */, 204 | 7A4A73B81F44820500F16956 /* Frameworks */, 205 | 7A4A73B91F44820500F16956 /* Resources */, 206 | ); 207 | buildRules = ( 208 | ); 209 | dependencies = ( 210 | 7A4A73BD1F44820500F16956 /* PBXTargetDependency */, 211 | ); 212 | name = ScrollPageControllDemoTests; 213 | productName = ScrollPageControllDemoTests; 214 | productReference = 7A4A73BB1F44820500F16956 /* ScrollPageControllDemoTests.xctest */; 215 | productType = "com.apple.product-type.bundle.unit-test"; 216 | }; 217 | 7A4A73C51F44820500F16956 /* ScrollPageControllDemoUITests */ = { 218 | isa = PBXNativeTarget; 219 | buildConfigurationList = 7A4A73D51F44820500F16956 /* Build configuration list for PBXNativeTarget "ScrollPageControllDemoUITests" */; 220 | buildPhases = ( 221 | 7A4A73C21F44820500F16956 /* Sources */, 222 | 7A4A73C31F44820500F16956 /* Frameworks */, 223 | 7A4A73C41F44820500F16956 /* Resources */, 224 | ); 225 | buildRules = ( 226 | ); 227 | dependencies = ( 228 | 7A4A73C81F44820500F16956 /* PBXTargetDependency */, 229 | ); 230 | name = ScrollPageControllDemoUITests; 231 | productName = ScrollPageControllDemoUITests; 232 | productReference = 7A4A73C61F44820500F16956 /* ScrollPageControllDemoUITests.xctest */; 233 | productType = "com.apple.product-type.bundle.ui-testing"; 234 | }; 235 | /* End PBXNativeTarget section */ 236 | 237 | /* Begin PBXProject section */ 238 | 7A4A739A1F44820400F16956 /* Project object */ = { 239 | isa = PBXProject; 240 | attributes = { 241 | LastUpgradeCheck = 0830; 242 | ORGANIZATIONNAME = "武传亮"; 243 | TargetAttributes = { 244 | 7A4A73A11F44820400F16956 = { 245 | CreatedOnToolsVersion = 8.3.1; 246 | ProvisioningStyle = Automatic; 247 | }; 248 | 7A4A73BA1F44820500F16956 = { 249 | CreatedOnToolsVersion = 8.3.1; 250 | ProvisioningStyle = Automatic; 251 | TestTargetID = 7A4A73A11F44820400F16956; 252 | }; 253 | 7A4A73C51F44820500F16956 = { 254 | CreatedOnToolsVersion = 8.3.1; 255 | ProvisioningStyle = Automatic; 256 | TestTargetID = 7A4A73A11F44820400F16956; 257 | }; 258 | }; 259 | }; 260 | buildConfigurationList = 7A4A739D1F44820400F16956 /* Build configuration list for PBXProject "ScrollPageControllDemo" */; 261 | compatibilityVersion = "Xcode 3.2"; 262 | developmentRegion = English; 263 | hasScannedForEncodings = 0; 264 | knownRegions = ( 265 | en, 266 | Base, 267 | ); 268 | mainGroup = 7A4A73991F44820400F16956; 269 | productRefGroup = 7A4A73A31F44820400F16956 /* Products */; 270 | projectDirPath = ""; 271 | projectRoot = ""; 272 | targets = ( 273 | 7A4A73A11F44820400F16956 /* ScrollPageControllDemo */, 274 | 7A4A73BA1F44820500F16956 /* ScrollPageControllDemoTests */, 275 | 7A4A73C51F44820500F16956 /* ScrollPageControllDemoUITests */, 276 | ); 277 | }; 278 | /* End PBXProject section */ 279 | 280 | /* Begin PBXResourcesBuildPhase section */ 281 | 7A4A73A01F44820400F16956 /* Resources */ = { 282 | isa = PBXResourcesBuildPhase; 283 | buildActionMask = 2147483647; 284 | files = ( 285 | 7A4A73B51F44820400F16956 /* LaunchScreen.storyboard in Resources */, 286 | 7A4A73B21F44820400F16956 /* Assets.xcassets in Resources */, 287 | 7A4A73B01F44820400F16956 /* Main.storyboard in Resources */, 288 | ); 289 | runOnlyForDeploymentPostprocessing = 0; 290 | }; 291 | 7A4A73B91F44820500F16956 /* Resources */ = { 292 | isa = PBXResourcesBuildPhase; 293 | buildActionMask = 2147483647; 294 | files = ( 295 | ); 296 | runOnlyForDeploymentPostprocessing = 0; 297 | }; 298 | 7A4A73C41F44820500F16956 /* Resources */ = { 299 | isa = PBXResourcesBuildPhase; 300 | buildActionMask = 2147483647; 301 | files = ( 302 | ); 303 | runOnlyForDeploymentPostprocessing = 0; 304 | }; 305 | /* End PBXResourcesBuildPhase section */ 306 | 307 | /* Begin PBXSourcesBuildPhase section */ 308 | 7A4A739E1F44820400F16956 /* Sources */ = { 309 | isa = PBXSourcesBuildPhase; 310 | buildActionMask = 2147483647; 311 | files = ( 312 | 7A008C571F66D67E00A7B79C /* SLScrollViewHorizontalItem.m in Sources */, 313 | 7A008C501F66D62F00A7B79C /* SLOneLineViewController.m in Sources */, 314 | 7A4A73AD1F44820400F16956 /* ViewController.m in Sources */, 315 | 7A008C531F66D63C00A7B79C /* SLMoreLineViewController.m in Sources */, 316 | 7A008C4D1F66D4A300A7B79C /* SLScrollViewOneLineItem.m in Sources */, 317 | 7A4A73AA1F44820400F16956 /* AppDelegate.m in Sources */, 318 | 7A4A73A71F44820400F16956 /* main.m in Sources */, 319 | ); 320 | runOnlyForDeploymentPostprocessing = 0; 321 | }; 322 | 7A4A73B71F44820500F16956 /* Sources */ = { 323 | isa = PBXSourcesBuildPhase; 324 | buildActionMask = 2147483647; 325 | files = ( 326 | 7A4A73C01F44820500F16956 /* ScrollPageControllDemoTests.m in Sources */, 327 | ); 328 | runOnlyForDeploymentPostprocessing = 0; 329 | }; 330 | 7A4A73C21F44820500F16956 /* Sources */ = { 331 | isa = PBXSourcesBuildPhase; 332 | buildActionMask = 2147483647; 333 | files = ( 334 | 7A4A73CB1F44820500F16956 /* ScrollPageControllDemoUITests.m in Sources */, 335 | ); 336 | runOnlyForDeploymentPostprocessing = 0; 337 | }; 338 | /* End PBXSourcesBuildPhase section */ 339 | 340 | /* Begin PBXTargetDependency section */ 341 | 7A4A73BD1F44820500F16956 /* PBXTargetDependency */ = { 342 | isa = PBXTargetDependency; 343 | target = 7A4A73A11F44820400F16956 /* ScrollPageControllDemo */; 344 | targetProxy = 7A4A73BC1F44820500F16956 /* PBXContainerItemProxy */; 345 | }; 346 | 7A4A73C81F44820500F16956 /* PBXTargetDependency */ = { 347 | isa = PBXTargetDependency; 348 | target = 7A4A73A11F44820400F16956 /* ScrollPageControllDemo */; 349 | targetProxy = 7A4A73C71F44820500F16956 /* PBXContainerItemProxy */; 350 | }; 351 | /* End PBXTargetDependency section */ 352 | 353 | /* Begin PBXVariantGroup section */ 354 | 7A4A73AE1F44820400F16956 /* Main.storyboard */ = { 355 | isa = PBXVariantGroup; 356 | children = ( 357 | 7A4A73AF1F44820400F16956 /* Base */, 358 | ); 359 | name = Main.storyboard; 360 | sourceTree = ""; 361 | }; 362 | 7A4A73B31F44820400F16956 /* LaunchScreen.storyboard */ = { 363 | isa = PBXVariantGroup; 364 | children = ( 365 | 7A4A73B41F44820400F16956 /* Base */, 366 | ); 367 | name = LaunchScreen.storyboard; 368 | sourceTree = ""; 369 | }; 370 | /* End PBXVariantGroup section */ 371 | 372 | /* Begin XCBuildConfiguration section */ 373 | 7A4A73CD1F44820500F16956 /* Debug */ = { 374 | isa = XCBuildConfiguration; 375 | buildSettings = { 376 | ALWAYS_SEARCH_USER_PATHS = NO; 377 | CLANG_ANALYZER_NONNULL = YES; 378 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 379 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 380 | CLANG_CXX_LIBRARY = "libc++"; 381 | CLANG_ENABLE_MODULES = YES; 382 | CLANG_ENABLE_OBJC_ARC = YES; 383 | CLANG_WARN_BOOL_CONVERSION = YES; 384 | CLANG_WARN_CONSTANT_CONVERSION = YES; 385 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 386 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 387 | CLANG_WARN_EMPTY_BODY = YES; 388 | CLANG_WARN_ENUM_CONVERSION = YES; 389 | CLANG_WARN_INFINITE_RECURSION = YES; 390 | CLANG_WARN_INT_CONVERSION = YES; 391 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 392 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 393 | CLANG_WARN_UNREACHABLE_CODE = YES; 394 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 395 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 396 | COPY_PHASE_STRIP = NO; 397 | DEBUG_INFORMATION_FORMAT = dwarf; 398 | ENABLE_STRICT_OBJC_MSGSEND = YES; 399 | ENABLE_TESTABILITY = YES; 400 | GCC_C_LANGUAGE_STANDARD = gnu99; 401 | GCC_DYNAMIC_NO_PIC = NO; 402 | GCC_NO_COMMON_BLOCKS = YES; 403 | GCC_OPTIMIZATION_LEVEL = 0; 404 | GCC_PREPROCESSOR_DEFINITIONS = ( 405 | "DEBUG=1", 406 | "$(inherited)", 407 | ); 408 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 409 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 410 | GCC_WARN_UNDECLARED_SELECTOR = YES; 411 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 412 | GCC_WARN_UNUSED_FUNCTION = YES; 413 | GCC_WARN_UNUSED_VARIABLE = YES; 414 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 415 | MTL_ENABLE_DEBUG_INFO = YES; 416 | ONLY_ACTIVE_ARCH = YES; 417 | SDKROOT = iphoneos; 418 | TARGETED_DEVICE_FAMILY = "1,2"; 419 | }; 420 | name = Debug; 421 | }; 422 | 7A4A73CE1F44820500F16956 /* Release */ = { 423 | isa = XCBuildConfiguration; 424 | buildSettings = { 425 | ALWAYS_SEARCH_USER_PATHS = NO; 426 | CLANG_ANALYZER_NONNULL = YES; 427 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 428 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 429 | CLANG_CXX_LIBRARY = "libc++"; 430 | CLANG_ENABLE_MODULES = YES; 431 | CLANG_ENABLE_OBJC_ARC = YES; 432 | CLANG_WARN_BOOL_CONVERSION = YES; 433 | CLANG_WARN_CONSTANT_CONVERSION = YES; 434 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 435 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 436 | CLANG_WARN_EMPTY_BODY = YES; 437 | CLANG_WARN_ENUM_CONVERSION = YES; 438 | CLANG_WARN_INFINITE_RECURSION = YES; 439 | CLANG_WARN_INT_CONVERSION = YES; 440 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 441 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 442 | CLANG_WARN_UNREACHABLE_CODE = YES; 443 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 444 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 445 | COPY_PHASE_STRIP = NO; 446 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 447 | ENABLE_NS_ASSERTIONS = NO; 448 | ENABLE_STRICT_OBJC_MSGSEND = YES; 449 | GCC_C_LANGUAGE_STANDARD = gnu99; 450 | GCC_NO_COMMON_BLOCKS = YES; 451 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 452 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 453 | GCC_WARN_UNDECLARED_SELECTOR = YES; 454 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 455 | GCC_WARN_UNUSED_FUNCTION = YES; 456 | GCC_WARN_UNUSED_VARIABLE = YES; 457 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 458 | MTL_ENABLE_DEBUG_INFO = NO; 459 | SDKROOT = iphoneos; 460 | TARGETED_DEVICE_FAMILY = "1,2"; 461 | VALIDATE_PRODUCT = YES; 462 | }; 463 | name = Release; 464 | }; 465 | 7A4A73D01F44820500F16956 /* Debug */ = { 466 | isa = XCBuildConfiguration; 467 | buildSettings = { 468 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 469 | INFOPLIST_FILE = ScrollPageControllDemo/Info.plist; 470 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 471 | PRODUCT_BUNDLE_IDENTIFIER = com.shanlianging.ScrollPageControllDemo; 472 | PRODUCT_NAME = "$(TARGET_NAME)"; 473 | }; 474 | name = Debug; 475 | }; 476 | 7A4A73D11F44820500F16956 /* Release */ = { 477 | isa = XCBuildConfiguration; 478 | buildSettings = { 479 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 480 | INFOPLIST_FILE = ScrollPageControllDemo/Info.plist; 481 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 482 | PRODUCT_BUNDLE_IDENTIFIER = com.shanlianging.ScrollPageControllDemo; 483 | PRODUCT_NAME = "$(TARGET_NAME)"; 484 | }; 485 | name = Release; 486 | }; 487 | 7A4A73D31F44820500F16956 /* Debug */ = { 488 | isa = XCBuildConfiguration; 489 | buildSettings = { 490 | BUNDLE_LOADER = "$(TEST_HOST)"; 491 | INFOPLIST_FILE = ScrollPageControllDemoTests/Info.plist; 492 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 493 | PRODUCT_BUNDLE_IDENTIFIER = com.shanlianging.ScrollPageControllDemoTests; 494 | PRODUCT_NAME = "$(TARGET_NAME)"; 495 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ScrollPageControllDemo.app/ScrollPageControllDemo"; 496 | }; 497 | name = Debug; 498 | }; 499 | 7A4A73D41F44820500F16956 /* Release */ = { 500 | isa = XCBuildConfiguration; 501 | buildSettings = { 502 | BUNDLE_LOADER = "$(TEST_HOST)"; 503 | INFOPLIST_FILE = ScrollPageControllDemoTests/Info.plist; 504 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 505 | PRODUCT_BUNDLE_IDENTIFIER = com.shanlianging.ScrollPageControllDemoTests; 506 | PRODUCT_NAME = "$(TARGET_NAME)"; 507 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ScrollPageControllDemo.app/ScrollPageControllDemo"; 508 | }; 509 | name = Release; 510 | }; 511 | 7A4A73D61F44820500F16956 /* Debug */ = { 512 | isa = XCBuildConfiguration; 513 | buildSettings = { 514 | INFOPLIST_FILE = ScrollPageControllDemoUITests/Info.plist; 515 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 516 | PRODUCT_BUNDLE_IDENTIFIER = com.shanlianging.ScrollPageControllDemoUITests; 517 | PRODUCT_NAME = "$(TARGET_NAME)"; 518 | TEST_TARGET_NAME = ScrollPageControllDemo; 519 | }; 520 | name = Debug; 521 | }; 522 | 7A4A73D71F44820500F16956 /* Release */ = { 523 | isa = XCBuildConfiguration; 524 | buildSettings = { 525 | INFOPLIST_FILE = ScrollPageControllDemoUITests/Info.plist; 526 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 527 | PRODUCT_BUNDLE_IDENTIFIER = com.shanlianging.ScrollPageControllDemoUITests; 528 | PRODUCT_NAME = "$(TARGET_NAME)"; 529 | TEST_TARGET_NAME = ScrollPageControllDemo; 530 | }; 531 | name = Release; 532 | }; 533 | /* End XCBuildConfiguration section */ 534 | 535 | /* Begin XCConfigurationList section */ 536 | 7A4A739D1F44820400F16956 /* Build configuration list for PBXProject "ScrollPageControllDemo" */ = { 537 | isa = XCConfigurationList; 538 | buildConfigurations = ( 539 | 7A4A73CD1F44820500F16956 /* Debug */, 540 | 7A4A73CE1F44820500F16956 /* Release */, 541 | ); 542 | defaultConfigurationIsVisible = 0; 543 | defaultConfigurationName = Release; 544 | }; 545 | 7A4A73CF1F44820500F16956 /* Build configuration list for PBXNativeTarget "ScrollPageControllDemo" */ = { 546 | isa = XCConfigurationList; 547 | buildConfigurations = ( 548 | 7A4A73D01F44820500F16956 /* Debug */, 549 | 7A4A73D11F44820500F16956 /* Release */, 550 | ); 551 | defaultConfigurationIsVisible = 0; 552 | defaultConfigurationName = Release; 553 | }; 554 | 7A4A73D21F44820500F16956 /* Build configuration list for PBXNativeTarget "ScrollPageControllDemoTests" */ = { 555 | isa = XCConfigurationList; 556 | buildConfigurations = ( 557 | 7A4A73D31F44820500F16956 /* Debug */, 558 | 7A4A73D41F44820500F16956 /* Release */, 559 | ); 560 | defaultConfigurationIsVisible = 0; 561 | defaultConfigurationName = Release; 562 | }; 563 | 7A4A73D51F44820500F16956 /* Build configuration list for PBXNativeTarget "ScrollPageControllDemoUITests" */ = { 564 | isa = XCConfigurationList; 565 | buildConfigurations = ( 566 | 7A4A73D61F44820500F16956 /* Debug */, 567 | 7A4A73D71F44820500F16956 /* Release */, 568 | ); 569 | defaultConfigurationIsVisible = 0; 570 | defaultConfigurationName = Release; 571 | }; 572 | /* End XCConfigurationList section */ 573 | }; 574 | rootObject = 7A4A739A1F44820400F16956 /* Project object */; 575 | } 576 | -------------------------------------------------------------------------------- /ScrollPageControllDemo/ScrollPageControllDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ScrollPageControllDemo/ScrollPageControllDemo.xcodeproj/project.xcworkspace/xcuserdata/wuchuanliang.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shanlianging/ScrollPageControll/67b5128702d06d1e5d4b66edfbc612e8da02e384/ScrollPageControllDemo/ScrollPageControllDemo.xcodeproj/project.xcworkspace/xcuserdata/wuchuanliang.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /ScrollPageControllDemo/ScrollPageControllDemo.xcodeproj/xcuserdata/wuchuanliang.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /ScrollPageControllDemo/ScrollPageControllDemo.xcodeproj/xcuserdata/wuchuanliang.xcuserdatad/xcschemes/ScrollPageControllDemo.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 | -------------------------------------------------------------------------------- /ScrollPageControllDemo/ScrollPageControllDemo.xcodeproj/xcuserdata/wuchuanliang.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ScrollPageControllDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 7A4A73A11F44820400F16956 16 | 17 | primary 18 | 19 | 20 | 7A4A73BA1F44820500F16956 21 | 22 | primary 23 | 24 | 25 | 7A4A73C51F44820500F16956 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /ScrollPageControllDemo/ScrollPageControllDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // ScrollPageControllDemo 4 | // 5 | // Created by 武传亮 on 2017/8/16. 6 | // Copyright © 2017年 武传亮. 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 | -------------------------------------------------------------------------------- /ScrollPageControllDemo/ScrollPageControllDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // ScrollPageControllDemo 4 | // 5 | // Created by 武传亮 on 2017/8/16. 6 | // Copyright © 2017年 武传亮. 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 | 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 invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // 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. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // 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. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /ScrollPageControllDemo/ScrollPageControllDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /ScrollPageControllDemo/ScrollPageControllDemo/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 | -------------------------------------------------------------------------------- /ScrollPageControllDemo/ScrollPageControllDemo/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 | 31 | 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 | -------------------------------------------------------------------------------- /ScrollPageControllDemo/ScrollPageControllDemo/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 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /ScrollPageControllDemo/ScrollPageControllDemo/SLMoreLineViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // SLMoreLineViewController.h 3 | // ScrollPageControllDemo 4 | // 5 | // Created by 武传亮 on 2017/9/11. 6 | // Copyright © 2017年 武传亮. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SLMoreLineViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ScrollPageControllDemo/ScrollPageControllDemo/SLMoreLineViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // SLMoreLineViewController.m 3 | // ScrollPageControllDemo 4 | // 5 | // Created by 武传亮 on 2017/9/11. 6 | // Copyright © 2017年 武传亮. All rights reserved. 7 | // 8 | 9 | #import "SLMoreLineViewController.h" 10 | #import "SLScrollViewHorizontalItem.h" 11 | 12 | @interface SLMoreLineViewController () 13 | @property (assign, nonatomic) NSInteger count; 14 | 15 | @property (strong, nonatomic) NSArray *dataArray; 16 | 17 | @property (strong, nonatomic) SLScrollViewHorizontalItem *scrollViewHorizontalItem; 18 | 19 | 20 | @end 21 | 22 | @implementation SLMoreLineViewController 23 | 24 | - (void)viewDidLoad { 25 | [super viewDidLoad]; 26 | 27 | self.navigationItem.title = @"SLMoreLineViewController"; 28 | 29 | self.view.backgroundColor = [UIColor whiteColor]; 30 | 31 | self.automaticallyAdjustsScrollViewInsets = NO; 32 | 33 | self.scrollViewHorizontalItem = [[SLScrollViewHorizontalItem alloc] initWithFrame:CGRectMake(0, 100, self.view.bounds.size.width, 200) delegate:self]; 34 | self.scrollViewHorizontalItem.backgroundColor = [UIColor colorWithRed:(218 / 255.0f) green:(255 / 255.0f) blue:(226 / 255.0f) alpha:1]; 35 | [self.view addSubview:self.scrollViewHorizontalItem]; 36 | 37 | NSMutableArray *array = [NSMutableArray new]; 38 | for (NSInteger i = 0; i < 11; i++) { 39 | [array addObject:@(i)]; 40 | } 41 | self.dataArray = array; 42 | 43 | UIActivityIndicatorView *activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; 44 | [self.view addSubview:activityIndicatorView]; 45 | activityIndicatorView.center = self.scrollViewHorizontalItem.center; 46 | 47 | [activityIndicatorView startAnimating]; 48 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 49 | [activityIndicatorView stopAnimating]; 50 | [self.scrollViewHorizontalItem updateView]; 51 | }); 52 | 53 | 54 | } 55 | 56 | - (NSInteger)numberOfItemsInView:(UIView *)view { 57 | return self.dataArray.count; 58 | } 59 | 60 | - (NSInteger)lineNumberOfItemsInView:(UIView *)view { 61 | return 2; 62 | } 63 | 64 | - (NSInteger)columnNumberOfItemsInView:(UIView *)view { 65 | return 4; 66 | } 67 | 68 | - (CGFloat)lineSpaceOfItemsInView:(UIView *)view { 69 | return 10; 70 | } 71 | 72 | - (CGFloat)columnSpaceOfItemsInView:(UIView *)view { 73 | return 10; 74 | } 75 | 76 | 77 | - (UIEdgeInsets)edgeInsetsOfItemsInView:(UIView *)view { 78 | return UIEdgeInsetsMake(10, 10, 10, 10); 79 | } 80 | 81 | - (UIView *)itemForView:(UIView *)view index:(NSInteger)index { 82 | 83 | UILabel *label = [[UILabel alloc] init]; 84 | label.backgroundColor = [UIColor brownColor]; 85 | label.textAlignment = NSTextAlignmentCenter; 86 | label.text = [NSString stringWithFormat:@"%ld", [self.dataArray[index] integerValue]]; 87 | 88 | return label; 89 | 90 | } 91 | 92 | - (void)item:(UIView *)item didSelectItemAtIndex:(NSInteger)index { 93 | NSLog(@"%ld", index); 94 | } 95 | 96 | //- (SLDistributionDirection)distributionDirectionAtView:(UIView *)view { 97 | // return SLDistributionDirectionVertical; 98 | //} 99 | 100 | 101 | 102 | 103 | @end 104 | -------------------------------------------------------------------------------- /ScrollPageControllDemo/ScrollPageControllDemo/SLOneLineViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // SLOneLineViewController.h 3 | // ScrollPageControllDemo 4 | // 5 | // Created by 武传亮 on 2017/9/11. 6 | // Copyright © 2017年 武传亮. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SLOneLineViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ScrollPageControllDemo/ScrollPageControllDemo/SLOneLineViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // SLOneLineViewController.m 3 | // ScrollPageControllDemo 4 | // 5 | // Created by 武传亮 on 2017/9/11. 6 | // Copyright © 2017年 武传亮. All rights reserved. 7 | // 8 | 9 | #import "SLOneLineViewController.h" 10 | #import "SLScrollViewOneLineItem.h" 11 | 12 | @interface SLOneLineViewController () 13 | 14 | 15 | /** */ 16 | @property (strong, nonatomic) SLScrollViewOneLineItem *scrollVHItem; 17 | @property (strong, nonatomic) NSArray *dataArray; 18 | 19 | 20 | @end 21 | 22 | @implementation SLOneLineViewController 23 | 24 | - (void)viewDidLoad { 25 | [super viewDidLoad]; 26 | 27 | 28 | self.navigationItem.title = @"SLOneLineViewController"; 29 | 30 | self.view.backgroundColor = [UIColor whiteColor]; 31 | 32 | self.automaticallyAdjustsScrollViewInsets = NO; 33 | 34 | 35 | 36 | [self.view addSubview:self.scrollVHItem]; 37 | 38 | 39 | UIActivityIndicatorView *activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; 40 | [self.view addSubview:activityIndicatorView]; 41 | activityIndicatorView.center = self.scrollVHItem.center; 42 | 43 | 44 | [activityIndicatorView startAnimating]; 45 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 46 | [activityIndicatorView stopAnimating]; 47 | 48 | NSMutableArray *array = [NSMutableArray new]; 49 | for (NSInteger i = 0; i < 11; i++) { 50 | [array addObject:@(i)]; 51 | } 52 | self.dataArray = array; 53 | 54 | [self.scrollVHItem removeFromSuperview]; 55 | self.scrollVHItem = nil; 56 | 57 | [self.scrollVHItem updateView]; 58 | [self.view addSubview:self.scrollVHItem]; 59 | 60 | }); 61 | 62 | 63 | 64 | 65 | } 66 | 67 | - (UIView *)itemForView:(UIView *)view index:(NSInteger)index { 68 | 69 | 70 | UILabel *label = [[UILabel alloc] init]; 71 | label.backgroundColor = [UIColor brownColor]; 72 | label.textAlignment = NSTextAlignmentCenter; 73 | label.text = [NSString stringWithFormat:@"%@", self.dataArray[index]]; 74 | 75 | return label; 76 | 77 | } 78 | 79 | 80 | 81 | -(NSInteger)numberOfItemsInView:(UIView *)view { 82 | 83 | return self.dataArray.count; 84 | } 85 | 86 | 87 | - (CGFloat)columnSpaceOfItemsInView:(UIView *)view { 88 | return 10.f; 89 | } 90 | 91 | - (UIEdgeInsets)edgeInsetsOfItemsInView:(UIView *)view { 92 | return UIEdgeInsetsMake(10, 10, 10, 10); 93 | } 94 | 95 | - (CGFloat)itemWidthForView:(UIView *)view { 96 | return 100; 97 | } 98 | 99 | - (void)item:(UIView *)item didSelectItemAtIndex:(NSInteger)index { 100 | 101 | 102 | NSLog(@"第 %ld 个", index); 103 | 104 | 105 | } 106 | 107 | #pragma mark - 108 | #pragma mark -- 懒加载 109 | 110 | 111 | - (SLScrollViewOneLineItem *)scrollVHItem { 112 | if (!_scrollVHItem) { 113 | _scrollVHItem = [[SLScrollViewOneLineItem alloc] initWithFrame:CGRectMake(0, 200, self.view.bounds.size.width, 100) delegate:self]; 114 | _scrollVHItem.scrollView.bounces = NO; 115 | _scrollVHItem.backgroundColor = [UIColor cyanColor]; 116 | 117 | } 118 | return _scrollVHItem; 119 | } 120 | 121 | 122 | 123 | 124 | 125 | 126 | @end 127 | -------------------------------------------------------------------------------- /ScrollPageControllDemo/ScrollPageControllDemo/SLScrollViewMoreLineItem/SLScrollViewHorizontalItem.h: -------------------------------------------------------------------------------- 1 | // 2 | // SLScrollViewHorizontalItem.h 3 | // ScrollPageControllTest 4 | // 5 | // Created by 武传亮 on 2017/8/14. 6 | // Copyright © 2017年 武传亮. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | typedef enum : NSUInteger { 13 | /** 横向排列 */ 14 | SLDistributionDirectionHorizontal, 15 | /** 纵向排列 */ 16 | SLDistributionDirectionVertical, 17 | } SLDistributionDirection; 18 | 19 | 20 | @protocol SLScrollViewHorizontalItemDelegate 21 | 22 | @required; 23 | 24 | /** 25 | item的个数 26 | 27 | @param view 视图 28 | @return item的个数 29 | */ 30 | - (NSInteger)numberOfItemsInView:(UIView *)view; 31 | 32 | 33 | /** 34 | item视图 35 | 36 | @param view 视图 37 | @param index item的位置 38 | @return item视图 39 | */ 40 | - (UIView *)itemForView:(UIView *)view index:(NSInteger)index; 41 | 42 | @optional 43 | 44 | /** 45 | 几行 46 | 47 | @param view 视图 48 | @return 行数 49 | */ 50 | - (NSInteger)lineNumberOfItemsInView:(UIView *)view; 51 | 52 | /** 53 | 几列 54 | 55 | @param view 视图 56 | @return 列数 57 | */ 58 | - (NSInteger)columnNumberOfItemsInView:(UIView *)view; 59 | 60 | /** 61 | item边缘距离 62 | 63 | @param view 视图 64 | @return item的边缘距离 65 | */ 66 | - (UIEdgeInsets)edgeInsetsOfItemsInView:(UIView *)view; 67 | 68 | /** 69 | item视图之间的行高 70 | 71 | @param view 视图 72 | @return 行高 73 | */ 74 | - (CGFloat)lineSpaceOfItemsInView:(UIView *)view; 75 | 76 | /** 77 | item视图之间的列宽 78 | 79 | @param view 视图 80 | @return 列宽 81 | */ 82 | - (CGFloat)columnSpaceOfItemsInView:(UIView *)view; 83 | 84 | /** 85 | 选中的item 86 | 87 | @param item 选中的item视图 88 | @param index item的下标 89 | */ 90 | - (void)item:(UIView *)item didSelectItemAtIndex:(NSInteger)index; 91 | 92 | 93 | /** 94 | 排布方向 95 | 96 | @param view 视图 97 | @return 方向 98 | */ 99 | - (SLDistributionDirection)distributionDirectionAtView:(UIView *)view; 100 | 101 | @end 102 | 103 | 104 | 105 | @interface SLScrollViewHorizontalItem : UIView 106 | 107 | /** 滑动视图 */ 108 | @property (strong, nonatomic) UIScrollView *scrollView; 109 | /** 页码控制器 */ 110 | @property (strong, nonatomic) UIPageControl *pageControl; 111 | 112 | /** 113 | 更新视图 114 | */ 115 | - (void)updateView; 116 | 117 | 118 | /** 119 | 创建视图 120 | 121 | @param frame 视图的frame 122 | @param delegate 视图的代理方法 123 | @return 视图实例 124 | */ 125 | - (instancetype)initWithFrame:(CGRect)frame delegate:(id)delegate; 126 | 127 | 128 | @end 129 | -------------------------------------------------------------------------------- /ScrollPageControllDemo/ScrollPageControllDemo/SLScrollViewMoreLineItem/SLScrollViewHorizontalItem.m: -------------------------------------------------------------------------------- 1 | // 2 | // SLScrollViewHorizontalItem.m 3 | // ScrollPageControllTest 4 | // 5 | // Created by 武传亮 on 2017/8/14. 6 | // Copyright © 2017年 武传亮. All rights reserved. 7 | // 8 | 9 | #import "SLScrollViewHorizontalItem.h" 10 | 11 | #define kTag 1001 12 | 13 | 14 | @interface SLScrollViewHorizontalItem () 15 | 16 | 17 | 18 | /** */ 19 | @property (weak, nonatomic) id delegate; 20 | 21 | /** 个数 */ 22 | @property (assign, nonatomic) NSInteger itemCounts; 23 | /** 行数 */ 24 | @property (assign, nonatomic) NSInteger lineNumber; 25 | /** 列数 */ 26 | @property (assign, nonatomic) NSInteger columnNumber; 27 | /** */ 28 | @property (assign, nonatomic) UIEdgeInsets edgeInsets; 29 | /** 行间距 */ 30 | @property (assign, nonatomic) CGFloat lineSpace; 31 | /** 列间距 */ 32 | @property (assign, nonatomic) CGFloat columnSpace; 33 | /** 排布方向 */ 34 | @property (assign, nonatomic) SLDistributionDirection distributionDirection; 35 | 36 | @end 37 | 38 | @implementation SLScrollViewHorizontalItem 39 | 40 | 41 | - (instancetype)initWithFrame:(CGRect)frame delegate:(id)delegate { 42 | 43 | self = [super initWithFrame:frame]; 44 | if (self) { 45 | 46 | _delegate = delegate; 47 | 48 | [self initValue]; 49 | 50 | [self setupView]; 51 | } 52 | return self; 53 | 54 | } 55 | 56 | - (void)initValue { 57 | 58 | _itemCounts = 10; 59 | _lineNumber = 2; 60 | _columnNumber = 4; 61 | _edgeInsets = UIEdgeInsetsMake(10, 10, 10, 10); 62 | _lineSpace = 10; 63 | _columnSpace = 10; 64 | _distributionDirection = SLDistributionDirectionHorizontal; 65 | 66 | 67 | if (_delegate && [_delegate respondsToSelector:@selector(numberOfItemsInView:)]) { 68 | _itemCounts = [_delegate numberOfItemsInView:self]; 69 | } 70 | if (_delegate && [_delegate respondsToSelector:@selector(lineNumberOfItemsInView:)]) { 71 | _lineNumber = [_delegate lineNumberOfItemsInView:self]; 72 | } 73 | if (_delegate && [_delegate respondsToSelector:@selector(columnNumberOfItemsInView:)]) { 74 | _columnNumber = [_delegate columnNumberOfItemsInView:self]; 75 | } 76 | if (_delegate && [_delegate respondsToSelector:@selector(edgeInsetsOfItemsInView:)]) { 77 | _edgeInsets = [_delegate edgeInsetsOfItemsInView:self]; 78 | } 79 | if (_delegate && [_delegate respondsToSelector:@selector(lineSpaceOfItemsInView:)]) { 80 | _lineSpace = [_delegate lineSpaceOfItemsInView:self]; 81 | } 82 | if (_delegate && [_delegate respondsToSelector:@selector(columnSpaceOfItemsInView:)]) { 83 | _columnSpace = [_delegate columnSpaceOfItemsInView:self]; 84 | } 85 | if (_delegate && [_delegate respondsToSelector:@selector(distributionDirectionAtView:)]) { 86 | _distributionDirection = [_delegate distributionDirectionAtView:self]; 87 | } 88 | 89 | } 90 | 91 | - (void)updateView { 92 | 93 | [self initValue]; 94 | 95 | [self setupView]; 96 | 97 | } 98 | 99 | 100 | - (void)setupView { 101 | 102 | for (UIView *view in self.scrollView.subviews) { 103 | [view removeFromSuperview]; 104 | } 105 | // self.scrollView = nil; 106 | 107 | [self addSubview:self.scrollView]; 108 | 109 | CGFloat width = (self.frame.size.width - (self.edgeInsets.left + self.edgeInsets.right + self.lineSpace * (self.columnNumber - 1))) / self.columnNumber; 110 | CGFloat height = (self.frame.size.height - (self.edgeInsets.top + self.edgeInsets.bottom + self.lineSpace * (self.lineNumber - 1))) / self.lineNumber; 111 | 112 | NSInteger pageCount = ceilf((CGFloat)self.itemCounts / (self.lineNumber * self.columnNumber)); 113 | 114 | self.scrollView.contentSize = CGSizeMake(self.frame.size.width * pageCount, self.frame.size.height); 115 | 116 | NSInteger countNumber = 0; 117 | 118 | 119 | self.pageControl.numberOfPages = pageCount; 120 | self.pageControl.pageIndicatorTintColor = [UIColor colorWithRed:(164 / 255.0f) green:(164 / 255.0f) blue:(164 / 255.0f) alpha:1]; 121 | self.pageControl.currentPageIndicatorTintColor = [UIColor colorWithRed:(73 / 255.0f) green:(73 / 255.0f) blue:(73 / 255.0f) alpha:1]; 122 | [self addSubview:self.pageControl]; 123 | 124 | 125 | 126 | switch (self.distributionDirection) { 127 | case SLDistributionDirectionHorizontal: 128 | 129 | // 几页 130 | for (NSInteger page = 0; page < pageCount; page ++) { 131 | 132 | // 几行 133 | for (NSInteger x = 0; x < self.lineNumber; x ++) { 134 | // 几列 135 | for (NSInteger y = 0; y < self.columnNumber; y ++) { 136 | 137 | if (countNumber == self.itemCounts) { 138 | return; 139 | } 140 | 141 | if (_delegate && [_delegate respondsToSelector:@selector(itemForView:index:)]) { 142 | UIView *view = [_delegate itemForView:self index:countNumber]; 143 | view.frame = CGRectMake(self.edgeInsets.left + (page * self.frame.size.width) + (y * (self.lineSpace + width)), self.edgeInsets.top + (x * (height + self.lineSpace)), width, height); 144 | [self.scrollView addSubview:view]; 145 | 146 | UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)]; 147 | [view addGestureRecognizer:tap]; 148 | view.tag = kTag + countNumber; 149 | view.userInteractionEnabled = YES; 150 | 151 | countNumber ++; 152 | 153 | } 154 | 155 | } 156 | } 157 | } 158 | 159 | break; 160 | case SLDistributionDirectionVertical: 161 | 162 | // 几页 163 | for (NSInteger page = 0; page < pageCount; page ++) { 164 | // 几列 165 | for (NSInteger y = 0; y < self.columnNumber; y ++) { 166 | // 几行 167 | for (NSInteger x = 0; x < self.lineNumber; x ++) { 168 | 169 | 170 | if (countNumber == self.itemCounts) { 171 | return; 172 | } 173 | 174 | if (_delegate && [_delegate respondsToSelector:@selector(itemForView:index:)]) { 175 | UIView *view = [_delegate itemForView:self index:countNumber]; 176 | view.frame = CGRectMake(self.edgeInsets.left + (page * self.frame.size.width) + (y * (self.lineSpace + width)), self.edgeInsets.top + (x * (height + self.lineSpace)), width, height); 177 | [self.scrollView addSubview:view]; 178 | 179 | UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)]; 180 | [view addGestureRecognizer:tap]; 181 | view.tag = kTag + countNumber; 182 | view.userInteractionEnabled = YES; 183 | 184 | countNumber ++; 185 | 186 | } 187 | 188 | } 189 | } 190 | } 191 | 192 | 193 | break; 194 | 195 | default: 196 | break; 197 | } 198 | 199 | 200 | } 201 | 202 | 203 | - (void)tapAction:(UITapGestureRecognizer *)tap { 204 | // NSLog(@"%ld", tap.view.tag - kTag); 205 | 206 | if (_delegate && [_delegate respondsToSelector:@selector(item:didSelectItemAtIndex:)]) { 207 | [_delegate item:tap.view didSelectItemAtIndex:tap.view.tag - kTag]; 208 | } 209 | } 210 | 211 | 212 | #pragma mark -- 懒加载 213 | - (UIScrollView *)scrollView { 214 | if (!_scrollView) { 215 | _scrollView = [[UIScrollView alloc] initWithFrame:self.bounds]; 216 | _scrollView.pagingEnabled = YES; 217 | // _scrollView.backgroundColor = [UIColor whiteColor]; 218 | _scrollView.showsVerticalScrollIndicator = NO; 219 | _scrollView.showsHorizontalScrollIndicator = NO; 220 | _scrollView.delegate = self; 221 | 222 | } 223 | return _scrollView; 224 | } 225 | 226 | 227 | 228 | 229 | #pragma mark -- UIScrollViewDelegate 230 | - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { 231 | NSInteger n = scrollView.contentOffset.x / scrollView.bounds.size.width; 232 | self.pageControl.currentPage = n; 233 | } 234 | 235 | 236 | 237 | @end 238 | -------------------------------------------------------------------------------- /ScrollPageControllDemo/ScrollPageControllDemo/SLScrollViewOneLineItem/SLScrollViewOneLineItem.h: -------------------------------------------------------------------------------- 1 | // 2 | // SLScrollViewOneLineItem.h 3 | // sudaizhijia 4 | // 5 | // Created by 武传亮 on 2017/9/7. 6 | // Copyright © 2017年 武传亮. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @protocol SLScrollViewOneLineItemDelegate 12 | 13 | @required; 14 | 15 | /** 16 | item的个数 17 | 18 | @param view 视图 19 | @return item的个数 20 | */ 21 | - (NSInteger)numberOfItemsInView:(UIView *)view; 22 | 23 | 24 | /** 25 | item视图 26 | 27 | @param view 视图 28 | @param index item的位置 29 | @return item视图 30 | */ 31 | - (UIView *)itemForView:(UIView *)view index:(NSInteger)index; 32 | 33 | @optional 34 | 35 | /** 36 | item视图的宽度 37 | 38 | @param view 视图 39 | @return 列宽 40 | */ 41 | - (CGFloat)itemWidthForView:(UIView *)view; 42 | 43 | 44 | /** 45 | item边缘距离 46 | 47 | @param view 视图 48 | @return item的边缘距离 49 | */ 50 | - (UIEdgeInsets)edgeInsetsOfItemsInView:(UIView *)view; 51 | 52 | 53 | /** 54 | item视图之间的列宽 55 | 56 | @param view 视图 57 | @return 列宽 58 | */ 59 | - (CGFloat)columnSpaceOfItemsInView:(UIView *)view; 60 | 61 | /** 62 | 选中的item 63 | 64 | @param item 选中的item视图 65 | @param index item的下标 66 | */ 67 | - (void)item:(UIView *)item didSelectItemAtIndex:(NSInteger)index; 68 | 69 | 70 | 71 | @end 72 | 73 | 74 | @interface SLScrollViewOneLineItem : UIView 75 | 76 | 77 | /** 滑动视图 */ 78 | @property (strong, nonatomic) UIScrollView *scrollView; 79 | 80 | /** 81 | 更新视图 82 | */ 83 | - (void)updateView; 84 | 85 | 86 | /** 87 | 创建视图 88 | 89 | @param frame 视图的frame 90 | @param delegate 视图的代理方法 91 | @return 视图实例 92 | */ 93 | - (instancetype)initWithFrame:(CGRect)frame delegate:(id)delegate; 94 | 95 | 96 | 97 | 98 | @end 99 | -------------------------------------------------------------------------------- /ScrollPageControllDemo/ScrollPageControllDemo/SLScrollViewOneLineItem/SLScrollViewOneLineItem.m: -------------------------------------------------------------------------------- 1 | // 2 | // SLScrollViewOneLineItem.m 3 | // sudaizhijia 4 | // 5 | // Created by 武传亮 on 2017/9/7. 6 | // Copyright © 2017年 武传亮. All rights reserved. 7 | // 8 | 9 | #import "SLScrollViewOneLineItem.h" 10 | 11 | #define kTag 2001 12 | 13 | // 指示器高度 14 | #define kIndicatorH 5 15 | // 指示器宽度 16 | #define kIndicatorW 16 17 | // 指示器背景宽度 18 | #define kIndicatorBackViewW 48 19 | 20 | @interface SLScrollViewOneLineItem () 21 | 22 | 23 | 24 | /** */ 25 | @property (weak, nonatomic) id delegate; 26 | 27 | /** 个数 */ 28 | @property (assign, nonatomic) NSInteger itemCounts; 29 | 30 | 31 | /** 边缘 */ 32 | @property (assign, nonatomic) UIEdgeInsets edgeInsets; 33 | 34 | 35 | /** 列间距 */ 36 | @property (assign, nonatomic) CGFloat columnSpace; 37 | 38 | /** item宽度 */ 39 | @property (assign, nonatomic) CGFloat itemWidth; 40 | 41 | 42 | /** 指示器背景 */ 43 | @property (strong, nonatomic) UIView *indicatorBackView; 44 | /** 指示器 */ 45 | @property (strong, nonatomic) UIView *indicatorView; 46 | 47 | 48 | @end 49 | 50 | @implementation SLScrollViewOneLineItem 51 | 52 | - (instancetype)initWithFrame:(CGRect)frame delegate:(id)delegate { 53 | 54 | self = [super initWithFrame:frame]; 55 | if (self) { 56 | 57 | _delegate = delegate; 58 | 59 | [self initValue]; 60 | 61 | [self setupView]; 62 | } 63 | return self; 64 | 65 | } 66 | 67 | - (void)initValue { 68 | 69 | _itemCounts = 10; 70 | _edgeInsets = UIEdgeInsetsMake(10, 10, 10, 10); 71 | _columnSpace = 10; 72 | _itemWidth = 100; 73 | 74 | if (_delegate && [_delegate respondsToSelector:@selector(numberOfItemsInView:)]) { 75 | _itemCounts = [_delegate numberOfItemsInView:self]; 76 | } 77 | 78 | if (_delegate && [_delegate respondsToSelector:@selector(edgeInsetsOfItemsInView:)]) { 79 | _edgeInsets = [_delegate edgeInsetsOfItemsInView:self]; 80 | } 81 | 82 | if (_delegate && [_delegate respondsToSelector:@selector(columnSpaceOfItemsInView:)]) { 83 | _columnSpace = [_delegate columnSpaceOfItemsInView:self]; 84 | } 85 | 86 | 87 | if (_delegate && [_delegate respondsToSelector:@selector(columnSpaceOfItemsInView:)]) { 88 | _itemWidth = [_delegate itemWidthForView:self]; 89 | } 90 | 91 | 92 | } 93 | 94 | - (void)updateView { 95 | 96 | [self initValue]; 97 | 98 | [self setupView]; 99 | 100 | } 101 | 102 | 103 | - (void)setupView { 104 | 105 | for (UIView *view in self.scrollView.subviews) { 106 | [view removeFromSuperview]; 107 | } 108 | 109 | [self addSubview:self.scrollView]; 110 | 111 | [self addSubview:self.indicatorBackView]; 112 | self.indicatorBackView.center = CGPointMake(self.center.x, CGRectGetMaxY(self.scrollView.frame) + 10); 113 | 114 | [self.indicatorBackView addSubview:self.indicatorView]; 115 | 116 | 117 | 118 | self.scrollView.contentSize = CGSizeMake((self.edgeInsets.left + self.edgeInsets.right + self.itemWidth * self.itemCounts + (self.itemCounts - 1) * self.columnSpace), self.frame.size.height); 119 | 120 | // NSInteger pageCount = ceilf(((self.itemWidth * self.itemCounts) + ((self.itemCounts - 1) * self.columnSpace) + self.edgeInsets.left + self.edgeInsets.right) / self.frame.size.width); 121 | 122 | 123 | // 几行 124 | for (NSInteger x = 0; x < self.itemCounts; x ++) { 125 | 126 | if (_delegate && [_delegate respondsToSelector:@selector(itemForView:index:)]) { 127 | 128 | UIView *view = [_delegate itemForView:self index:x]; 129 | 130 | CGRect frame = view.frame; 131 | frame.origin.x = self.edgeInsets.left + (self.itemWidth * x) + (self.columnSpace * x); 132 | frame.origin.y = 0; 133 | frame.size.width = self.itemWidth; 134 | frame.size.height = self.scrollView.frame.size.height; 135 | view.frame = frame; 136 | 137 | [self.scrollView addSubview:view]; 138 | 139 | UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)]; 140 | [view addGestureRecognizer:tap]; 141 | view.tag = kTag + x; 142 | view.userInteractionEnabled = YES; 143 | 144 | } 145 | 146 | } 147 | 148 | 149 | } 150 | 151 | 152 | - (void)tapAction:(UITapGestureRecognizer *)tap { 153 | 154 | if (_delegate && [_delegate respondsToSelector:@selector(item:didSelectItemAtIndex:)]) { 155 | [_delegate item:tap.view didSelectItemAtIndex:tap.view.tag - kTag]; 156 | } 157 | } 158 | 159 | 160 | #pragma mark - 161 | #pragma mark -- UIScrollViewDelegate 162 | 163 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView { 164 | 165 | CGRect frame = self.indicatorView.frame; 166 | frame.origin.x = scrollView.contentOffset.x * (kIndicatorBackViewW - kIndicatorW) / (scrollView.contentSize.width - self.frame.size.width); 167 | self.indicatorView.frame = frame; 168 | 169 | } 170 | 171 | 172 | #pragma mark - 173 | #pragma mark -- 懒加载 174 | - (UIScrollView *)scrollView { 175 | if (!_scrollView) { 176 | _scrollView = [[UIScrollView alloc] initWithFrame:self.bounds]; 177 | _scrollView.pagingEnabled = NO; 178 | _scrollView.showsVerticalScrollIndicator = NO; 179 | _scrollView.showsHorizontalScrollIndicator = NO; 180 | _scrollView.delegate = self; 181 | } 182 | return _scrollView; 183 | } 184 | 185 | 186 | - (UIView *)indicatorBackView { 187 | if (!_indicatorBackView) { 188 | _indicatorBackView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kIndicatorBackViewW, kIndicatorH)]; 189 | _indicatorBackView.backgroundColor = [UIColor whiteColor]; 190 | _indicatorBackView.layer.borderWidth = 1; 191 | _indicatorBackView.layer.borderColor = [UIColor blueColor].CGColor; 192 | } 193 | return _indicatorBackView; 194 | } 195 | 196 | - (UIView *)indicatorView { 197 | if (!_indicatorView) { 198 | _indicatorView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kIndicatorW, kIndicatorH)]; 199 | _indicatorView.backgroundColor = [UIColor redColor]; 200 | } 201 | return _indicatorView; 202 | } 203 | 204 | 205 | 206 | 207 | @end 208 | -------------------------------------------------------------------------------- /ScrollPageControllDemo/ScrollPageControllDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // ScrollPageControllDemo 4 | // 5 | // Created by 武传亮 on 2017/8/16. 6 | // Copyright © 2017年 武传亮. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /ScrollPageControllDemo/ScrollPageControllDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // ScrollPageControllDemo 4 | // 5 | // Created by 武传亮 on 2017/8/16. 6 | // Copyright © 2017年 武传亮. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "SLOneLineViewController.h" 11 | #import "SLMoreLineViewController.h" 12 | 13 | 14 | @interface ViewController () 15 | 16 | 17 | 18 | @end 19 | 20 | @implementation ViewController 21 | 22 | - (void)viewDidLoad { 23 | [super viewDidLoad]; 24 | 25 | self.navigationItem.title = @"ScrollPageControllDemo"; 26 | 27 | 28 | } 29 | 30 | 31 | - (IBAction)oneAction:(UIButton *)sender { 32 | 33 | SLOneLineViewController *one = [SLOneLineViewController new]; 34 | [self.navigationController pushViewController:one animated:YES]; 35 | 36 | 37 | } 38 | 39 | 40 | - (IBAction)moreAction:(id)sender { 41 | 42 | SLMoreLineViewController *more = [SLMoreLineViewController new]; 43 | [self.navigationController pushViewController:more animated:YES]; 44 | 45 | 46 | } 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /ScrollPageControllDemo/ScrollPageControllDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // ScrollPageControllDemo 4 | // 5 | // Created by 武传亮 on 2017/8/16. 6 | // Copyright © 2017年 武传亮. 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 | -------------------------------------------------------------------------------- /ScrollPageControllDemo/ScrollPageControllDemoTests/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 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /ScrollPageControllDemo/ScrollPageControllDemoTests/ScrollPageControllDemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // ScrollPageControllDemoTests.m 3 | // ScrollPageControllDemoTests 4 | // 5 | // Created by 武传亮 on 2017/8/16. 6 | // Copyright © 2017年 武传亮. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ScrollPageControllDemoTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation ScrollPageControllDemoTests 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 | -------------------------------------------------------------------------------- /ScrollPageControllDemo/ScrollPageControllDemoUITests/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 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /ScrollPageControllDemo/ScrollPageControllDemoUITests/ScrollPageControllDemoUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // ScrollPageControllDemoUITests.m 3 | // ScrollPageControllDemoUITests 4 | // 5 | // Created by 武传亮 on 2017/8/16. 6 | // Copyright © 2017年 武传亮. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ScrollPageControllDemoUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation ScrollPageControllDemoUITests 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 | -------------------------------------------------------------------------------- /image/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shanlianging/ScrollPageControll/67b5128702d06d1e5d4b66edfbc612e8da02e384/image/demo.gif -------------------------------------------------------------------------------- /image/horizontal.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shanlianging/ScrollPageControll/67b5128702d06d1e5d4b66edfbc612e8da02e384/image/horizontal.gif -------------------------------------------------------------------------------- /image/vertical.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shanlianging/ScrollPageControll/67b5128702d06d1e5d4b66edfbc612e8da02e384/image/vertical.gif --------------------------------------------------------------------------------