├── .gitignore ├── LICENSE ├── Proj ├── Demo.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── Demo │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── DetailViewController.swift │ ├── Info.plist │ ├── NavSampleViewController.swift │ ├── SampleData.swift │ ├── StartViewController.swift │ ├── ViewController.swift │ └── sample_header_image.jpg ├── ViewPagerController.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── ViewPagerController.xcscheme ├── ViewPagerController.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist ├── ViewPagerController │ ├── Info.plist │ └── ViewPagerController.h └── ViewPagerControllerTests │ ├── Info.plist │ └── ViewPagerControllerTests.swift ├── README.md ├── Sources ├── InfiniteScrollView.swift ├── Info.plist ├── PagerContainerView.swift ├── PagerTabMenuView.swift ├── UIColor+RGBA.swift ├── UIView+AutoLayout.swift ├── ViewPagerController+ScrollHeaderSupport.swift ├── ViewPagerController.h ├── ViewPagerController.swift └── ViewPagerControllerAppearance.swift ├── ViewPagerController.podspec ├── capture1.gif └── capture2.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # OS X 2 | .DS_Store 3 | 4 | # Xcode 5 | # build/ 6 | *.pbxuser 7 | !default.pbxuser 8 | *.mode1v3 9 | !default.mode1v3 10 | *.mode2v3 11 | !default.mode2v3 12 | *.perspectivev3 13 | !default.perspectivev3 14 | xcuserdata 15 | *.xccheckout 16 | profile 17 | *.moved-aside 18 | DerivedData 19 | *.hmap 20 | *.ipa 21 | 22 | # Bundler 23 | .bundle 24 | 25 | # We recommend against adding the Pods directory to your .gitignore. However 26 | # you should judge for yourself, the pros and cons are mentioned at: 27 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 28 | # 29 | # Note: if you ignore the Pods directory, make sure to uncomment 30 | # `pod install` in .travis.yml 31 | # 32 | # Pods/ 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 xxxAIRINxxx 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /Proj/Demo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 91192BFC1C83FF0100051F4E /* ViewPagerController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 91192BF71C83FEF100051F4E /* ViewPagerController.framework */; }; 11 | 91192BFD1C83FF0100051F4E /* ViewPagerController.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 91192BF71C83FEF100051F4E /* ViewPagerController.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 12 | 9188C7A51C72DACB004FFAEF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9188C7A41C72DACB004FFAEF /* AppDelegate.swift */; }; 13 | 9188C7A71C72DACB004FFAEF /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9188C7A61C72DACB004FFAEF /* ViewController.swift */; }; 14 | 9188C7AA1C72DACB004FFAEF /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9188C7A81C72DACB004FFAEF /* Main.storyboard */; }; 15 | 9188C7AC1C72DACB004FFAEF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9188C7AB1C72DACB004FFAEF /* Assets.xcassets */; }; 16 | 9188C7AF1C72DACB004FFAEF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9188C7AD1C72DACB004FFAEF /* LaunchScreen.storyboard */; }; 17 | 9188C7C11C72DB6C004FFAEF /* DetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9188C7C01C72DB6C004FFAEF /* DetailViewController.swift */; }; 18 | 9188C7C61C72DB76004FFAEF /* NavSampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9188C7C21C72DB76004FFAEF /* NavSampleViewController.swift */; }; 19 | 9188C7C71C72DB76004FFAEF /* sample_header_image.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 9188C7C31C72DB76004FFAEF /* sample_header_image.jpg */; }; 20 | 9188C7C81C72DB76004FFAEF /* SampleData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9188C7C41C72DB76004FFAEF /* SampleData.swift */; }; 21 | 9188C7C91C72DB76004FFAEF /* StartViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9188C7C51C72DB76004FFAEF /* StartViewController.swift */; }; 22 | /* End PBXBuildFile section */ 23 | 24 | /* Begin PBXContainerItemProxy section */ 25 | 91192BF61C83FEF100051F4E /* PBXContainerItemProxy */ = { 26 | isa = PBXContainerItemProxy; 27 | containerPortal = 91192BF11C83FEF100051F4E /* ViewPagerController.xcodeproj */; 28 | proxyType = 2; 29 | remoteGlobalIDString = 9188C7691C72D9D0004FFAEF; 30 | remoteInfo = ViewPagerController; 31 | }; 32 | 91192BF81C83FEF100051F4E /* PBXContainerItemProxy */ = { 33 | isa = PBXContainerItemProxy; 34 | containerPortal = 91192BF11C83FEF100051F4E /* ViewPagerController.xcodeproj */; 35 | proxyType = 2; 36 | remoteGlobalIDString = 9188C7731C72D9D0004FFAEF; 37 | remoteInfo = ViewPagerControllerTests; 38 | }; 39 | 91192BFA1C83FEFB00051F4E /* PBXContainerItemProxy */ = { 40 | isa = PBXContainerItemProxy; 41 | containerPortal = 91192BF11C83FEF100051F4E /* ViewPagerController.xcodeproj */; 42 | proxyType = 1; 43 | remoteGlobalIDString = 9188C7681C72D9D0004FFAEF; 44 | remoteInfo = ViewPagerController; 45 | }; 46 | 91192BFE1C83FF0100051F4E /* PBXContainerItemProxy */ = { 47 | isa = PBXContainerItemProxy; 48 | containerPortal = 91192BF11C83FEF100051F4E /* ViewPagerController.xcodeproj */; 49 | proxyType = 1; 50 | remoteGlobalIDString = 9188C7681C72D9D0004FFAEF; 51 | remoteInfo = ViewPagerController; 52 | }; 53 | /* End PBXContainerItemProxy section */ 54 | 55 | /* Begin PBXCopyFilesBuildPhase section */ 56 | 9188C7BF1C72DB52004FFAEF /* Embed Frameworks */ = { 57 | isa = PBXCopyFilesBuildPhase; 58 | buildActionMask = 2147483647; 59 | dstPath = ""; 60 | dstSubfolderSpec = 10; 61 | files = ( 62 | 91192BFD1C83FF0100051F4E /* ViewPagerController.framework in Embed Frameworks */, 63 | ); 64 | name = "Embed Frameworks"; 65 | runOnlyForDeploymentPostprocessing = 0; 66 | }; 67 | /* End PBXCopyFilesBuildPhase section */ 68 | 69 | /* Begin PBXFileReference section */ 70 | 91192BF11C83FEF100051F4E /* ViewPagerController.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = ViewPagerController.xcodeproj; sourceTree = ""; }; 71 | 9188C7A11C72DACB004FFAEF /* Demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Demo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 72 | 9188C7A41C72DACB004FFAEF /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 73 | 9188C7A61C72DACB004FFAEF /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 74 | 9188C7A91C72DACB004FFAEF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 75 | 9188C7AB1C72DACB004FFAEF /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 76 | 9188C7AE1C72DACB004FFAEF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 77 | 9188C7B01C72DACB004FFAEF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 78 | 9188C7C01C72DB6C004FFAEF /* DetailViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DetailViewController.swift; sourceTree = ""; }; 79 | 9188C7C21C72DB76004FFAEF /* NavSampleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NavSampleViewController.swift; sourceTree = ""; }; 80 | 9188C7C31C72DB76004FFAEF /* sample_header_image.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = sample_header_image.jpg; sourceTree = ""; }; 81 | 9188C7C41C72DB76004FFAEF /* SampleData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SampleData.swift; sourceTree = ""; }; 82 | 9188C7C51C72DB76004FFAEF /* StartViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StartViewController.swift; sourceTree = ""; }; 83 | /* End PBXFileReference section */ 84 | 85 | /* Begin PBXFrameworksBuildPhase section */ 86 | 9188C79E1C72DACB004FFAEF /* Frameworks */ = { 87 | isa = PBXFrameworksBuildPhase; 88 | buildActionMask = 2147483647; 89 | files = ( 90 | 91192BFC1C83FF0100051F4E /* ViewPagerController.framework in Frameworks */, 91 | ); 92 | runOnlyForDeploymentPostprocessing = 0; 93 | }; 94 | /* End PBXFrameworksBuildPhase section */ 95 | 96 | /* Begin PBXGroup section */ 97 | 91192BF21C83FEF100051F4E /* Products */ = { 98 | isa = PBXGroup; 99 | children = ( 100 | 91192BF71C83FEF100051F4E /* ViewPagerController.framework */, 101 | 91192BF91C83FEF100051F4E /* ViewPagerControllerTests.xctest */, 102 | ); 103 | name = Products; 104 | sourceTree = ""; 105 | }; 106 | 9188C7981C72DACB004FFAEF = { 107 | isa = PBXGroup; 108 | children = ( 109 | 91192BF11C83FEF100051F4E /* ViewPagerController.xcodeproj */, 110 | 9188C7A31C72DACB004FFAEF /* Demo */, 111 | 9188C7A21C72DACB004FFAEF /* Products */, 112 | ); 113 | sourceTree = ""; 114 | }; 115 | 9188C7A21C72DACB004FFAEF /* Products */ = { 116 | isa = PBXGroup; 117 | children = ( 118 | 9188C7A11C72DACB004FFAEF /* Demo.app */, 119 | ); 120 | name = Products; 121 | sourceTree = ""; 122 | }; 123 | 9188C7A31C72DACB004FFAEF /* Demo */ = { 124 | isa = PBXGroup; 125 | children = ( 126 | 9188C7A41C72DACB004FFAEF /* AppDelegate.swift */, 127 | 9188C7A61C72DACB004FFAEF /* ViewController.swift */, 128 | 9188C7C01C72DB6C004FFAEF /* DetailViewController.swift */, 129 | 9188C7C21C72DB76004FFAEF /* NavSampleViewController.swift */, 130 | 9188C7C51C72DB76004FFAEF /* StartViewController.swift */, 131 | 9188C7C41C72DB76004FFAEF /* SampleData.swift */, 132 | 9188C7C31C72DB76004FFAEF /* sample_header_image.jpg */, 133 | 9188C7A81C72DACB004FFAEF /* Main.storyboard */, 134 | 9188C7AB1C72DACB004FFAEF /* Assets.xcassets */, 135 | 9188C7AD1C72DACB004FFAEF /* LaunchScreen.storyboard */, 136 | 9188C7B01C72DACB004FFAEF /* Info.plist */, 137 | ); 138 | path = Demo; 139 | sourceTree = ""; 140 | }; 141 | /* End PBXGroup section */ 142 | 143 | /* Begin PBXNativeTarget section */ 144 | 9188C7A01C72DACB004FFAEF /* Demo */ = { 145 | isa = PBXNativeTarget; 146 | buildConfigurationList = 9188C7B31C72DACB004FFAEF /* Build configuration list for PBXNativeTarget "Demo" */; 147 | buildPhases = ( 148 | 9188C79D1C72DACB004FFAEF /* Sources */, 149 | 9188C79E1C72DACB004FFAEF /* Frameworks */, 150 | 9188C79F1C72DACB004FFAEF /* Resources */, 151 | 9188C7BF1C72DB52004FFAEF /* Embed Frameworks */, 152 | ); 153 | buildRules = ( 154 | ); 155 | dependencies = ( 156 | 91192BFB1C83FEFB00051F4E /* PBXTargetDependency */, 157 | 91192BFF1C83FF0100051F4E /* PBXTargetDependency */, 158 | ); 159 | name = Demo; 160 | productName = Demo; 161 | productReference = 9188C7A11C72DACB004FFAEF /* Demo.app */; 162 | productType = "com.apple.product-type.application"; 163 | }; 164 | /* End PBXNativeTarget section */ 165 | 166 | /* Begin PBXProject section */ 167 | 9188C7991C72DACB004FFAEF /* Project object */ = { 168 | isa = PBXProject; 169 | attributes = { 170 | LastSwiftUpdateCheck = 0720; 171 | LastUpgradeCheck = 0930; 172 | ORGANIZATIONNAME = xxxAIRINxxx; 173 | TargetAttributes = { 174 | 9188C7A01C72DACB004FFAEF = { 175 | CreatedOnToolsVersion = 7.2.1; 176 | DevelopmentTeam = P599PJHMNF; 177 | LastSwiftMigration = 0930; 178 | }; 179 | }; 180 | }; 181 | buildConfigurationList = 9188C79C1C72DACB004FFAEF /* Build configuration list for PBXProject "Demo" */; 182 | compatibilityVersion = "Xcode 3.2"; 183 | developmentRegion = English; 184 | hasScannedForEncodings = 0; 185 | knownRegions = ( 186 | en, 187 | Base, 188 | ); 189 | mainGroup = 9188C7981C72DACB004FFAEF; 190 | productRefGroup = 9188C7A21C72DACB004FFAEF /* Products */; 191 | projectDirPath = ""; 192 | projectReferences = ( 193 | { 194 | ProductGroup = 91192BF21C83FEF100051F4E /* Products */; 195 | ProjectRef = 91192BF11C83FEF100051F4E /* ViewPagerController.xcodeproj */; 196 | }, 197 | ); 198 | projectRoot = ""; 199 | targets = ( 200 | 9188C7A01C72DACB004FFAEF /* Demo */, 201 | ); 202 | }; 203 | /* End PBXProject section */ 204 | 205 | /* Begin PBXReferenceProxy section */ 206 | 91192BF71C83FEF100051F4E /* ViewPagerController.framework */ = { 207 | isa = PBXReferenceProxy; 208 | fileType = wrapper.framework; 209 | path = ViewPagerController.framework; 210 | remoteRef = 91192BF61C83FEF100051F4E /* PBXContainerItemProxy */; 211 | sourceTree = BUILT_PRODUCTS_DIR; 212 | }; 213 | 91192BF91C83FEF100051F4E /* ViewPagerControllerTests.xctest */ = { 214 | isa = PBXReferenceProxy; 215 | fileType = wrapper.cfbundle; 216 | path = ViewPagerControllerTests.xctest; 217 | remoteRef = 91192BF81C83FEF100051F4E /* PBXContainerItemProxy */; 218 | sourceTree = BUILT_PRODUCTS_DIR; 219 | }; 220 | /* End PBXReferenceProxy section */ 221 | 222 | /* Begin PBXResourcesBuildPhase section */ 223 | 9188C79F1C72DACB004FFAEF /* Resources */ = { 224 | isa = PBXResourcesBuildPhase; 225 | buildActionMask = 2147483647; 226 | files = ( 227 | 9188C7AF1C72DACB004FFAEF /* LaunchScreen.storyboard in Resources */, 228 | 9188C7AC1C72DACB004FFAEF /* Assets.xcassets in Resources */, 229 | 9188C7C71C72DB76004FFAEF /* sample_header_image.jpg in Resources */, 230 | 9188C7AA1C72DACB004FFAEF /* Main.storyboard in Resources */, 231 | ); 232 | runOnlyForDeploymentPostprocessing = 0; 233 | }; 234 | /* End PBXResourcesBuildPhase section */ 235 | 236 | /* Begin PBXSourcesBuildPhase section */ 237 | 9188C79D1C72DACB004FFAEF /* Sources */ = { 238 | isa = PBXSourcesBuildPhase; 239 | buildActionMask = 2147483647; 240 | files = ( 241 | 9188C7C11C72DB6C004FFAEF /* DetailViewController.swift in Sources */, 242 | 9188C7A71C72DACB004FFAEF /* ViewController.swift in Sources */, 243 | 9188C7C61C72DB76004FFAEF /* NavSampleViewController.swift in Sources */, 244 | 9188C7C81C72DB76004FFAEF /* SampleData.swift in Sources */, 245 | 9188C7A51C72DACB004FFAEF /* AppDelegate.swift in Sources */, 246 | 9188C7C91C72DB76004FFAEF /* StartViewController.swift in Sources */, 247 | ); 248 | runOnlyForDeploymentPostprocessing = 0; 249 | }; 250 | /* End PBXSourcesBuildPhase section */ 251 | 252 | /* Begin PBXTargetDependency section */ 253 | 91192BFB1C83FEFB00051F4E /* PBXTargetDependency */ = { 254 | isa = PBXTargetDependency; 255 | name = ViewPagerController; 256 | targetProxy = 91192BFA1C83FEFB00051F4E /* PBXContainerItemProxy */; 257 | }; 258 | 91192BFF1C83FF0100051F4E /* PBXTargetDependency */ = { 259 | isa = PBXTargetDependency; 260 | name = ViewPagerController; 261 | targetProxy = 91192BFE1C83FF0100051F4E /* PBXContainerItemProxy */; 262 | }; 263 | /* End PBXTargetDependency section */ 264 | 265 | /* Begin PBXVariantGroup section */ 266 | 9188C7A81C72DACB004FFAEF /* Main.storyboard */ = { 267 | isa = PBXVariantGroup; 268 | children = ( 269 | 9188C7A91C72DACB004FFAEF /* Base */, 270 | ); 271 | name = Main.storyboard; 272 | sourceTree = ""; 273 | }; 274 | 9188C7AD1C72DACB004FFAEF /* LaunchScreen.storyboard */ = { 275 | isa = PBXVariantGroup; 276 | children = ( 277 | 9188C7AE1C72DACB004FFAEF /* Base */, 278 | ); 279 | name = LaunchScreen.storyboard; 280 | sourceTree = ""; 281 | }; 282 | /* End PBXVariantGroup section */ 283 | 284 | /* Begin XCBuildConfiguration section */ 285 | 9188C7B11C72DACB004FFAEF /* Debug */ = { 286 | isa = XCBuildConfiguration; 287 | buildSettings = { 288 | ALWAYS_SEARCH_USER_PATHS = NO; 289 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 290 | CLANG_CXX_LIBRARY = "libc++"; 291 | CLANG_ENABLE_MODULES = YES; 292 | CLANG_ENABLE_OBJC_ARC = YES; 293 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 294 | CLANG_WARN_BOOL_CONVERSION = YES; 295 | CLANG_WARN_COMMA = YES; 296 | CLANG_WARN_CONSTANT_CONVERSION = YES; 297 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 298 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 299 | CLANG_WARN_EMPTY_BODY = YES; 300 | CLANG_WARN_ENUM_CONVERSION = YES; 301 | CLANG_WARN_INFINITE_RECURSION = YES; 302 | CLANG_WARN_INT_CONVERSION = YES; 303 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 304 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 305 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 306 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 307 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 308 | CLANG_WARN_STRICT_PROTOTYPES = YES; 309 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 310 | CLANG_WARN_UNREACHABLE_CODE = YES; 311 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 312 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 313 | COPY_PHASE_STRIP = NO; 314 | DEBUG_INFORMATION_FORMAT = dwarf; 315 | ENABLE_STRICT_OBJC_MSGSEND = YES; 316 | ENABLE_TESTABILITY = YES; 317 | GCC_C_LANGUAGE_STANDARD = gnu99; 318 | GCC_DYNAMIC_NO_PIC = NO; 319 | GCC_NO_COMMON_BLOCKS = YES; 320 | GCC_OPTIMIZATION_LEVEL = 0; 321 | GCC_PREPROCESSOR_DEFINITIONS = ( 322 | "DEBUG=1", 323 | "$(inherited)", 324 | ); 325 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 326 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 327 | GCC_WARN_UNDECLARED_SELECTOR = YES; 328 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 329 | GCC_WARN_UNUSED_FUNCTION = YES; 330 | GCC_WARN_UNUSED_VARIABLE = YES; 331 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 332 | MTL_ENABLE_DEBUG_INFO = YES; 333 | ONLY_ACTIVE_ARCH = YES; 334 | SDKROOT = iphoneos; 335 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 336 | }; 337 | name = Debug; 338 | }; 339 | 9188C7B21C72DACB004FFAEF /* Release */ = { 340 | isa = XCBuildConfiguration; 341 | buildSettings = { 342 | ALWAYS_SEARCH_USER_PATHS = NO; 343 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 344 | CLANG_CXX_LIBRARY = "libc++"; 345 | CLANG_ENABLE_MODULES = YES; 346 | CLANG_ENABLE_OBJC_ARC = YES; 347 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 348 | CLANG_WARN_BOOL_CONVERSION = YES; 349 | CLANG_WARN_COMMA = YES; 350 | CLANG_WARN_CONSTANT_CONVERSION = YES; 351 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 352 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 353 | CLANG_WARN_EMPTY_BODY = YES; 354 | CLANG_WARN_ENUM_CONVERSION = YES; 355 | CLANG_WARN_INFINITE_RECURSION = YES; 356 | CLANG_WARN_INT_CONVERSION = YES; 357 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 358 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 359 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 360 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 361 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 362 | CLANG_WARN_STRICT_PROTOTYPES = YES; 363 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 364 | CLANG_WARN_UNREACHABLE_CODE = YES; 365 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 366 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 367 | COPY_PHASE_STRIP = NO; 368 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 369 | ENABLE_NS_ASSERTIONS = NO; 370 | ENABLE_STRICT_OBJC_MSGSEND = YES; 371 | GCC_C_LANGUAGE_STANDARD = gnu99; 372 | GCC_NO_COMMON_BLOCKS = YES; 373 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 374 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 375 | GCC_WARN_UNDECLARED_SELECTOR = YES; 376 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 377 | GCC_WARN_UNUSED_FUNCTION = YES; 378 | GCC_WARN_UNUSED_VARIABLE = YES; 379 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 380 | MTL_ENABLE_DEBUG_INFO = NO; 381 | SDKROOT = iphoneos; 382 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 383 | VALIDATE_PRODUCT = YES; 384 | }; 385 | name = Release; 386 | }; 387 | 9188C7B41C72DACB004FFAEF /* Debug */ = { 388 | isa = XCBuildConfiguration; 389 | buildSettings = { 390 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 391 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 392 | DEVELOPMENT_TEAM = P599PJHMNF; 393 | INFOPLIST_FILE = Demo/Info.plist; 394 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 395 | PRODUCT_BUNDLE_IDENTIFIER = xxxAIRINxxx.Demo; 396 | PRODUCT_NAME = "$(TARGET_NAME)"; 397 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 398 | SWIFT_VERSION = 4.0; 399 | }; 400 | name = Debug; 401 | }; 402 | 9188C7B51C72DACB004FFAEF /* Release */ = { 403 | isa = XCBuildConfiguration; 404 | buildSettings = { 405 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 406 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 407 | DEVELOPMENT_TEAM = P599PJHMNF; 408 | INFOPLIST_FILE = Demo/Info.plist; 409 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 410 | PRODUCT_BUNDLE_IDENTIFIER = xxxAIRINxxx.Demo; 411 | PRODUCT_NAME = "$(TARGET_NAME)"; 412 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 413 | SWIFT_VERSION = 4.0; 414 | }; 415 | name = Release; 416 | }; 417 | /* End XCBuildConfiguration section */ 418 | 419 | /* Begin XCConfigurationList section */ 420 | 9188C79C1C72DACB004FFAEF /* Build configuration list for PBXProject "Demo" */ = { 421 | isa = XCConfigurationList; 422 | buildConfigurations = ( 423 | 9188C7B11C72DACB004FFAEF /* Debug */, 424 | 9188C7B21C72DACB004FFAEF /* Release */, 425 | ); 426 | defaultConfigurationIsVisible = 0; 427 | defaultConfigurationName = Release; 428 | }; 429 | 9188C7B31C72DACB004FFAEF /* Build configuration list for PBXNativeTarget "Demo" */ = { 430 | isa = XCConfigurationList; 431 | buildConfigurations = ( 432 | 9188C7B41C72DACB004FFAEF /* Debug */, 433 | 9188C7B51C72DACB004FFAEF /* Release */, 434 | ); 435 | defaultConfigurationIsVisible = 0; 436 | defaultConfigurationName = Release; 437 | }; 438 | /* End XCConfigurationList section */ 439 | }; 440 | rootObject = 9188C7991C72DACB004FFAEF /* Project object */; 441 | } 442 | -------------------------------------------------------------------------------- /Proj/Demo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Proj/Demo/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // Demo 4 | // 5 | // Created by xxxAIRINxxx on 2016/01/05. 6 | // Copyright © 2016 xxxAIRINxxx. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 17 | return true 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /Proj/Demo/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 | } -------------------------------------------------------------------------------- /Proj/Demo/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 | -------------------------------------------------------------------------------- /Proj/Demo/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 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | -------------------------------------------------------------------------------- /Proj/Demo/DetailViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DetailViewController.swift 3 | // Demo 4 | // 5 | // Created by xxxAIRINxxx on 2016/01/05. 6 | // Copyright © 2016 xxxAIRINxxx. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | final class DetailViewController: UIViewController, UITableViewDataSource, UITableViewDelegate { 12 | 13 | weak var parentController : UIViewController? 14 | 15 | @IBOutlet weak var tableView : UITableView! 16 | 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | } 20 | 21 | override func viewWillAppear(_ animated: Bool) { 22 | super.viewWillAppear(animated) 23 | print("DetailViewController viewWillAppear - " + self.title!) 24 | } 25 | 26 | override func viewWillDisappear(_ animated: Bool) { 27 | super.viewWillDisappear(animated) 28 | print("DetailViewController viewWillDisappear - " + self.title!) 29 | } 30 | 31 | // MARK: - UITableViewDataSource 32 | 33 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 34 | return 40 35 | } 36 | 37 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 38 | let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) 39 | cell.textLabel?.text = self.title 40 | return cell 41 | } 42 | 43 | // MARK: - UITableViewDelegate 44 | 45 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 46 | tableView.deselectRow(at: indexPath, animated: true) 47 | 48 | let storyboard = UIStoryboard(name: "Main", bundle: nil) 49 | let controller = storyboard.instantiateViewController(withIdentifier: "DetailViewController") as! DetailViewController 50 | controller.view.clipsToBounds = true 51 | controller.title = "pushed " + self.title! 52 | 53 | self.parentController?.navigationController?.pushViewController(controller, animated: true) 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Proj/Demo/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 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /Proj/Demo/NavSampleViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NavSampleViewController.swift 3 | // Demo 4 | // 5 | // Created by xxxAIRINxxx on 2016/01/05. 6 | // Copyright © 2016 xxxAIRINxxx. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import ViewPagerController 11 | 12 | class NavSampleViewController : UIViewController { 13 | 14 | @IBOutlet weak var layerView : UIView! 15 | 16 | var pagerController : ViewPagerController? 17 | 18 | override func viewDidLoad() { 19 | super.viewDidLoad() 20 | 21 | let pagerController = ViewPagerController() 22 | pagerController.setParentController(self, parentView: self.layerView) 23 | 24 | var appearance = ViewPagerControllerAppearance() 25 | 26 | appearance.tabMenuHeight = 44.0 27 | appearance.scrollViewMinPositionY = 20.0 28 | appearance.scrollViewObservingType = .navigationBar(targetNavigationBar: self.navigationController!.navigationBar) 29 | 30 | appearance.tabMenuAppearance.backgroundColor = UIColor.darkGray 31 | appearance.tabMenuAppearance.selectedViewBackgroundColor = UIColor.blue 32 | appearance.tabMenuAppearance.selectedViewInsets = UIEdgeInsets(top: 39, left: 0, bottom: 0, right: 0) 33 | 34 | pagerController.updateAppearance(appearance) 35 | 36 | pagerController.willBeginTabMenuUserScrollingHandler = { selectedView in 37 | selectedView.alpha = 0.0 38 | } 39 | 40 | pagerController.didEndTabMenuUserScrollingHandler = { selectedView in 41 | selectedView.alpha = 1.0 42 | } 43 | 44 | pagerController.changeObserveScrollViewHandler = { controller in 45 | let detailController = controller as! DetailViewController 46 | 47 | return detailController.tableView 48 | } 49 | 50 | pagerController.didChangeHeaderViewHeightHandler = { height in 51 | print("call didShowViewControllerHandler : \(height)") 52 | } 53 | 54 | for title in sampleDataTitles { 55 | let controller = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "DetailViewController") as! DetailViewController 56 | controller.view.clipsToBounds = true 57 | controller.title = title 58 | controller.parentController = self 59 | pagerController.addContent(title, viewController: controller) 60 | } 61 | 62 | self.pagerController = pagerController 63 | 64 | self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "remove", style: .plain, target: self, action: #selector(NavSampleViewController.remove)) 65 | } 66 | 67 | @objc fileprivate func remove() { 68 | guard let c = self.pagerController?.childViewControllers.first else { return } 69 | self.pagerController?.removeContent(c) 70 | } 71 | 72 | override func viewWillDisappear(_ animated: Bool) { 73 | super.viewWillDisappear(animated) 74 | 75 | self.pagerController?.resetNavigationBarHeight(true) 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /Proj/Demo/SampleData.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SampleData.swift 3 | // Demo 4 | // 5 | // Created by xxxAIRINxxx on 2016/01/05. 6 | // Copyright © 2016 xxxAIRINxxx. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | let sampleDataTitles : [String] = [ 12 | "1 Ranking", 13 | "2 Favorite", 14 | "3 s", 15 | "4 Pick Up", 16 | "5 Lifestyle", 17 | "6 ---------- Long Title ---------- ", 18 | "7 Sale", 19 | "8 Music", 20 | "9 News", 21 | "10 Sample Download", 22 | ] 23 | -------------------------------------------------------------------------------- /Proj/Demo/StartViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // StartViewController.swift 3 | // Demo 4 | // 5 | // Created by xxxAIRINxxx on 2016/01/05. 6 | // Copyright © 2016 xxxAIRINxxx. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class StartViewController: UITableViewController { 12 | 13 | // MARK: - UITableViewDataSource 14 | 15 | override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 16 | return 2 17 | } 18 | 19 | override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 20 | if (indexPath as NSIndexPath).row == 0 { 21 | let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) 22 | return cell 23 | } 24 | if (indexPath as NSIndexPath).row == 1 { 25 | let cell = tableView.dequeueReusableCell(withIdentifier: "Cell2", for: indexPath) 26 | return cell 27 | } 28 | 29 | return UITableViewCell() 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Proj/Demo/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // Demo 4 | // 5 | // Created by xxxAIRINxxx on 2016/01/05. 6 | // Copyright © 2016 xxxAIRINxxx. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import ViewPagerController 11 | 12 | final class ViewController: UIViewController { 13 | 14 | @IBOutlet weak var layerView : UIView! 15 | 16 | var pagerController : ViewPagerController? 17 | 18 | override func viewDidLoad() { 19 | super.viewDidLoad() 20 | 21 | let pagerController = ViewPagerController() 22 | pagerController.setParentController(self, parentView: self.layerView) 23 | 24 | var appearance = ViewPagerControllerAppearance() 25 | 26 | appearance.headerHeight = 200.0 27 | appearance.scrollViewMinPositionY = 20.0 28 | appearance.scrollViewObservingType = .header 29 | 30 | let imageView = UIImageView(image: UIImage(named: "sample_header_image.jpg")) 31 | imageView.contentMode = .scaleAspectFill 32 | imageView.clipsToBounds = true 33 | appearance.headerContentsView = imageView 34 | 35 | appearance.tabMenuAppearance.selectedViewBackgroundColor = UIColor.green 36 | appearance.tabMenuAppearance.selectedViewInsets = UIEdgeInsets(top: 10, left: 5, bottom: 10, right: 5) 37 | 38 | pagerController.updateAppearance(appearance) 39 | 40 | pagerController.updateSelectedViewHandler = { selectedView in 41 | selectedView.layer.cornerRadius = selectedView.frame.size.height * 0.5 42 | } 43 | 44 | pagerController.willBeginTabMenuUserScrollingHandler = { selectedView in 45 | print("call willBeginTabMenuUserScrollingHandler") 46 | selectedView.alpha = 0.0 47 | } 48 | 49 | pagerController.didEndTabMenuUserScrollingHandler = { selectedView in 50 | print("call didEndTabMenuUserScrollingHandler") 51 | selectedView.alpha = 1.0 52 | } 53 | 54 | pagerController.didShowViewControllerHandler = { controller in 55 | print("call didShowViewControllerHandler") 56 | print("controller : \(String(describing: controller.title))") 57 | let currentController = pagerController.currentContent() 58 | print("currentContent : \(String(describing: currentController?.title))") 59 | } 60 | 61 | pagerController.changeObserveScrollViewHandler = { controller in 62 | print("call didShowViewControllerObservingHandler") 63 | let detailController = controller as! DetailViewController 64 | 65 | return detailController.tableView 66 | } 67 | 68 | pagerController.didChangeHeaderViewHeightHandler = { height in 69 | print("call didChangeHeaderViewHeightHandler : \(height)") 70 | } 71 | 72 | pagerController.didScrollContentHandler = { percentComplete in 73 | print("call didScrollContentHandler : \(percentComplete)") 74 | } 75 | 76 | for title in sampleDataTitles { 77 | let controller = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "DetailViewController") as! DetailViewController 78 | controller.view.clipsToBounds = true 79 | controller.title = title 80 | controller.parentController = self 81 | pagerController.addContent(title, viewController: controller) 82 | } 83 | 84 | self.pagerController = pagerController 85 | } 86 | 87 | override func viewWillAppear(_ animated: Bool) { 88 | super.viewWillAppear(animated) 89 | self.navigationController?.isNavigationBarHidden = true 90 | } 91 | 92 | override func viewDidDisappear(_ animated: Bool) { 93 | super.viewDidDisappear(animated) 94 | self.navigationController?.isNavigationBarHidden = false 95 | } 96 | } 97 | 98 | -------------------------------------------------------------------------------- /Proj/Demo/sample_header_image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xxxAIRINxxx/ViewPagerController/7c28a509daf8a53007a6ed610086e07891379fbb/Proj/Demo/sample_header_image.jpg -------------------------------------------------------------------------------- /Proj/ViewPagerController.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 9188C7741C72D9D0004FFAEF /* ViewPagerController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9188C7691C72D9D0004FFAEF /* ViewPagerController.framework */; }; 11 | 9188C7791C72D9D0004FFAEF /* ViewPagerControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9188C7781C72D9D0004FFAEF /* ViewPagerControllerTests.swift */; }; 12 | 9188C78E1C72DA6F004FFAEF /* InfiniteScrollView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9188C7841C72DA6F004FFAEF /* InfiniteScrollView.swift */; }; 13 | 9188C78F1C72DA6F004FFAEF /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 9188C7851C72DA6F004FFAEF /* Info.plist */; }; 14 | 9188C7901C72DA6F004FFAEF /* PagerContainerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9188C7861C72DA6F004FFAEF /* PagerContainerView.swift */; }; 15 | 9188C7911C72DA6F004FFAEF /* PagerTabMenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9188C7871C72DA6F004FFAEF /* PagerTabMenuView.swift */; }; 16 | 9188C7921C72DA6F004FFAEF /* UIColor+RGBA.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9188C7881C72DA6F004FFAEF /* UIColor+RGBA.swift */; }; 17 | 9188C7931C72DA6F004FFAEF /* UIView+AutoLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9188C7891C72DA6F004FFAEF /* UIView+AutoLayout.swift */; }; 18 | 9188C7941C72DA6F004FFAEF /* ViewPagerController+ScrollHeaderSupport.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9188C78A1C72DA6F004FFAEF /* ViewPagerController+ScrollHeaderSupport.swift */; }; 19 | 9188C7951C72DA6F004FFAEF /* ViewPagerController.h in Headers */ = {isa = PBXBuildFile; fileRef = 9188C78B1C72DA6F004FFAEF /* ViewPagerController.h */; settings = {ATTRIBUTES = (Public, ); }; }; 20 | 9188C7961C72DA6F004FFAEF /* ViewPagerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9188C78C1C72DA6F004FFAEF /* ViewPagerController.swift */; }; 21 | 9188C7971C72DA6F004FFAEF /* ViewPagerControllerAppearance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9188C78D1C72DA6F004FFAEF /* ViewPagerControllerAppearance.swift */; }; 22 | /* End PBXBuildFile section */ 23 | 24 | /* Begin PBXContainerItemProxy section */ 25 | 9188C7751C72D9D0004FFAEF /* PBXContainerItemProxy */ = { 26 | isa = PBXContainerItemProxy; 27 | containerPortal = 9188C7601C72D9CF004FFAEF /* Project object */; 28 | proxyType = 1; 29 | remoteGlobalIDString = 9188C7681C72D9D0004FFAEF; 30 | remoteInfo = ViewPagerController; 31 | }; 32 | 9188C7BA1C72DAF4004FFAEF /* PBXContainerItemProxy */ = { 33 | isa = PBXContainerItemProxy; 34 | containerPortal = 9188C7B61C72DAF4004FFAEF /* Demo.xcodeproj */; 35 | proxyType = 2; 36 | remoteGlobalIDString = 9188C7A11C72DACB004FFAEF; 37 | remoteInfo = Demo; 38 | }; 39 | /* End PBXContainerItemProxy section */ 40 | 41 | /* Begin PBXFileReference section */ 42 | 9188C7691C72D9D0004FFAEF /* ViewPagerController.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ViewPagerController.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | 9188C7731C72D9D0004FFAEF /* ViewPagerControllerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ViewPagerControllerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 44 | 9188C7781C72D9D0004FFAEF /* ViewPagerControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewPagerControllerTests.swift; sourceTree = ""; }; 45 | 9188C77A1C72D9D0004FFAEF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 46 | 9188C7841C72DA6F004FFAEF /* InfiniteScrollView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InfiniteScrollView.swift; sourceTree = ""; }; 47 | 9188C7851C72DA6F004FFAEF /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 48 | 9188C7861C72DA6F004FFAEF /* PagerContainerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PagerContainerView.swift; sourceTree = ""; }; 49 | 9188C7871C72DA6F004FFAEF /* PagerTabMenuView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PagerTabMenuView.swift; sourceTree = ""; }; 50 | 9188C7881C72DA6F004FFAEF /* UIColor+RGBA.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIColor+RGBA.swift"; sourceTree = ""; }; 51 | 9188C7891C72DA6F004FFAEF /* UIView+AutoLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIView+AutoLayout.swift"; sourceTree = ""; }; 52 | 9188C78A1C72DA6F004FFAEF /* ViewPagerController+ScrollHeaderSupport.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ViewPagerController+ScrollHeaderSupport.swift"; sourceTree = ""; }; 53 | 9188C78B1C72DA6F004FFAEF /* ViewPagerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewPagerController.h; sourceTree = ""; }; 54 | 9188C78C1C72DA6F004FFAEF /* ViewPagerController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewPagerController.swift; sourceTree = ""; }; 55 | 9188C78D1C72DA6F004FFAEF /* ViewPagerControllerAppearance.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewPagerControllerAppearance.swift; sourceTree = ""; }; 56 | 9188C7B61C72DAF4004FFAEF /* Demo.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = Demo.xcodeproj; sourceTree = ""; }; 57 | /* End PBXFileReference section */ 58 | 59 | /* Begin PBXFrameworksBuildPhase section */ 60 | 9188C7651C72D9D0004FFAEF /* Frameworks */ = { 61 | isa = PBXFrameworksBuildPhase; 62 | buildActionMask = 2147483647; 63 | files = ( 64 | ); 65 | runOnlyForDeploymentPostprocessing = 0; 66 | }; 67 | 9188C7701C72D9D0004FFAEF /* Frameworks */ = { 68 | isa = PBXFrameworksBuildPhase; 69 | buildActionMask = 2147483647; 70 | files = ( 71 | 9188C7741C72D9D0004FFAEF /* ViewPagerController.framework in Frameworks */, 72 | ); 73 | runOnlyForDeploymentPostprocessing = 0; 74 | }; 75 | /* End PBXFrameworksBuildPhase section */ 76 | 77 | /* Begin PBXGroup section */ 78 | 9188C75F1C72D9CF004FFAEF = { 79 | isa = PBXGroup; 80 | children = ( 81 | 9188C7831C72DA6F004FFAEF /* Sources */, 82 | 9188C7771C72D9D0004FFAEF /* ViewPagerControllerTests */, 83 | 9188C76A1C72D9D0004FFAEF /* Products */, 84 | 9188C7B61C72DAF4004FFAEF /* Demo.xcodeproj */, 85 | ); 86 | sourceTree = ""; 87 | }; 88 | 9188C76A1C72D9D0004FFAEF /* Products */ = { 89 | isa = PBXGroup; 90 | children = ( 91 | 9188C7691C72D9D0004FFAEF /* ViewPagerController.framework */, 92 | 9188C7731C72D9D0004FFAEF /* ViewPagerControllerTests.xctest */, 93 | ); 94 | name = Products; 95 | sourceTree = ""; 96 | }; 97 | 9188C7771C72D9D0004FFAEF /* ViewPagerControllerTests */ = { 98 | isa = PBXGroup; 99 | children = ( 100 | 9188C7781C72D9D0004FFAEF /* ViewPagerControllerTests.swift */, 101 | 9188C77A1C72D9D0004FFAEF /* Info.plist */, 102 | ); 103 | path = ViewPagerControllerTests; 104 | sourceTree = ""; 105 | }; 106 | 9188C7831C72DA6F004FFAEF /* Sources */ = { 107 | isa = PBXGroup; 108 | children = ( 109 | 9188C7851C72DA6F004FFAEF /* Info.plist */, 110 | 9188C78B1C72DA6F004FFAEF /* ViewPagerController.h */, 111 | 9188C78C1C72DA6F004FFAEF /* ViewPagerController.swift */, 112 | 9188C7841C72DA6F004FFAEF /* InfiniteScrollView.swift */, 113 | 9188C7861C72DA6F004FFAEF /* PagerContainerView.swift */, 114 | 9188C7871C72DA6F004FFAEF /* PagerTabMenuView.swift */, 115 | 9188C7881C72DA6F004FFAEF /* UIColor+RGBA.swift */, 116 | 9188C7891C72DA6F004FFAEF /* UIView+AutoLayout.swift */, 117 | 9188C78A1C72DA6F004FFAEF /* ViewPagerController+ScrollHeaderSupport.swift */, 118 | 9188C78D1C72DA6F004FFAEF /* ViewPagerControllerAppearance.swift */, 119 | ); 120 | name = Sources; 121 | path = ../Sources; 122 | sourceTree = ""; 123 | }; 124 | 9188C7B71C72DAF4004FFAEF /* Products */ = { 125 | isa = PBXGroup; 126 | children = ( 127 | 9188C7BB1C72DAF4004FFAEF /* Demo.app */, 128 | ); 129 | name = Products; 130 | sourceTree = ""; 131 | }; 132 | /* End PBXGroup section */ 133 | 134 | /* Begin PBXHeadersBuildPhase section */ 135 | 9188C7661C72D9D0004FFAEF /* Headers */ = { 136 | isa = PBXHeadersBuildPhase; 137 | buildActionMask = 2147483647; 138 | files = ( 139 | 9188C7951C72DA6F004FFAEF /* ViewPagerController.h in Headers */, 140 | ); 141 | runOnlyForDeploymentPostprocessing = 0; 142 | }; 143 | /* End PBXHeadersBuildPhase section */ 144 | 145 | /* Begin PBXNativeTarget section */ 146 | 9188C7681C72D9D0004FFAEF /* ViewPagerController */ = { 147 | isa = PBXNativeTarget; 148 | buildConfigurationList = 9188C77D1C72D9D0004FFAEF /* Build configuration list for PBXNativeTarget "ViewPagerController" */; 149 | buildPhases = ( 150 | 9188C7641C72D9D0004FFAEF /* Sources */, 151 | 9188C7651C72D9D0004FFAEF /* Frameworks */, 152 | 9188C7661C72D9D0004FFAEF /* Headers */, 153 | 9188C7671C72D9D0004FFAEF /* Resources */, 154 | ); 155 | buildRules = ( 156 | ); 157 | dependencies = ( 158 | ); 159 | name = ViewPagerController; 160 | productName = ViewPagerController; 161 | productReference = 9188C7691C72D9D0004FFAEF /* ViewPagerController.framework */; 162 | productType = "com.apple.product-type.framework"; 163 | }; 164 | 9188C7721C72D9D0004FFAEF /* ViewPagerControllerTests */ = { 165 | isa = PBXNativeTarget; 166 | buildConfigurationList = 9188C7801C72D9D0004FFAEF /* Build configuration list for PBXNativeTarget "ViewPagerControllerTests" */; 167 | buildPhases = ( 168 | 9188C76F1C72D9D0004FFAEF /* Sources */, 169 | 9188C7701C72D9D0004FFAEF /* Frameworks */, 170 | 9188C7711C72D9D0004FFAEF /* Resources */, 171 | ); 172 | buildRules = ( 173 | ); 174 | dependencies = ( 175 | 9188C7761C72D9D0004FFAEF /* PBXTargetDependency */, 176 | ); 177 | name = ViewPagerControllerTests; 178 | productName = ViewPagerControllerTests; 179 | productReference = 9188C7731C72D9D0004FFAEF /* ViewPagerControllerTests.xctest */; 180 | productType = "com.apple.product-type.bundle.unit-test"; 181 | }; 182 | /* End PBXNativeTarget section */ 183 | 184 | /* Begin PBXProject section */ 185 | 9188C7601C72D9CF004FFAEF /* Project object */ = { 186 | isa = PBXProject; 187 | attributes = { 188 | LastSwiftUpdateCheck = 0720; 189 | LastUpgradeCheck = 0930; 190 | ORGANIZATIONNAME = xxxAIRINxxx; 191 | TargetAttributes = { 192 | 9188C7681C72D9D0004FFAEF = { 193 | CreatedOnToolsVersion = 7.2.1; 194 | LastSwiftMigration = 0930; 195 | }; 196 | 9188C7721C72D9D0004FFAEF = { 197 | CreatedOnToolsVersion = 7.2.1; 198 | }; 199 | }; 200 | }; 201 | buildConfigurationList = 9188C7631C72D9CF004FFAEF /* Build configuration list for PBXProject "ViewPagerController" */; 202 | compatibilityVersion = "Xcode 3.2"; 203 | developmentRegion = English; 204 | hasScannedForEncodings = 0; 205 | knownRegions = ( 206 | en, 207 | ); 208 | mainGroup = 9188C75F1C72D9CF004FFAEF; 209 | productRefGroup = 9188C76A1C72D9D0004FFAEF /* Products */; 210 | projectDirPath = ""; 211 | projectReferences = ( 212 | { 213 | ProductGroup = 9188C7B71C72DAF4004FFAEF /* Products */; 214 | ProjectRef = 9188C7B61C72DAF4004FFAEF /* Demo.xcodeproj */; 215 | }, 216 | ); 217 | projectRoot = ""; 218 | targets = ( 219 | 9188C7681C72D9D0004FFAEF /* ViewPagerController */, 220 | 9188C7721C72D9D0004FFAEF /* ViewPagerControllerTests */, 221 | ); 222 | }; 223 | /* End PBXProject section */ 224 | 225 | /* Begin PBXReferenceProxy section */ 226 | 9188C7BB1C72DAF4004FFAEF /* Demo.app */ = { 227 | isa = PBXReferenceProxy; 228 | fileType = wrapper.application; 229 | path = Demo.app; 230 | remoteRef = 9188C7BA1C72DAF4004FFAEF /* PBXContainerItemProxy */; 231 | sourceTree = BUILT_PRODUCTS_DIR; 232 | }; 233 | /* End PBXReferenceProxy section */ 234 | 235 | /* Begin PBXResourcesBuildPhase section */ 236 | 9188C7671C72D9D0004FFAEF /* Resources */ = { 237 | isa = PBXResourcesBuildPhase; 238 | buildActionMask = 2147483647; 239 | files = ( 240 | 9188C78F1C72DA6F004FFAEF /* Info.plist in Resources */, 241 | ); 242 | runOnlyForDeploymentPostprocessing = 0; 243 | }; 244 | 9188C7711C72D9D0004FFAEF /* Resources */ = { 245 | isa = PBXResourcesBuildPhase; 246 | buildActionMask = 2147483647; 247 | files = ( 248 | ); 249 | runOnlyForDeploymentPostprocessing = 0; 250 | }; 251 | /* End PBXResourcesBuildPhase section */ 252 | 253 | /* Begin PBXSourcesBuildPhase section */ 254 | 9188C7641C72D9D0004FFAEF /* Sources */ = { 255 | isa = PBXSourcesBuildPhase; 256 | buildActionMask = 2147483647; 257 | files = ( 258 | 9188C7931C72DA6F004FFAEF /* UIView+AutoLayout.swift in Sources */, 259 | 9188C7901C72DA6F004FFAEF /* PagerContainerView.swift in Sources */, 260 | 9188C7921C72DA6F004FFAEF /* UIColor+RGBA.swift in Sources */, 261 | 9188C7911C72DA6F004FFAEF /* PagerTabMenuView.swift in Sources */, 262 | 9188C7971C72DA6F004FFAEF /* ViewPagerControllerAppearance.swift in Sources */, 263 | 9188C7941C72DA6F004FFAEF /* ViewPagerController+ScrollHeaderSupport.swift in Sources */, 264 | 9188C78E1C72DA6F004FFAEF /* InfiniteScrollView.swift in Sources */, 265 | 9188C7961C72DA6F004FFAEF /* ViewPagerController.swift in Sources */, 266 | ); 267 | runOnlyForDeploymentPostprocessing = 0; 268 | }; 269 | 9188C76F1C72D9D0004FFAEF /* Sources */ = { 270 | isa = PBXSourcesBuildPhase; 271 | buildActionMask = 2147483647; 272 | files = ( 273 | 9188C7791C72D9D0004FFAEF /* ViewPagerControllerTests.swift in Sources */, 274 | ); 275 | runOnlyForDeploymentPostprocessing = 0; 276 | }; 277 | /* End PBXSourcesBuildPhase section */ 278 | 279 | /* Begin PBXTargetDependency section */ 280 | 9188C7761C72D9D0004FFAEF /* PBXTargetDependency */ = { 281 | isa = PBXTargetDependency; 282 | target = 9188C7681C72D9D0004FFAEF /* ViewPagerController */; 283 | targetProxy = 9188C7751C72D9D0004FFAEF /* PBXContainerItemProxy */; 284 | }; 285 | /* End PBXTargetDependency section */ 286 | 287 | /* Begin XCBuildConfiguration section */ 288 | 9188C77B1C72D9D0004FFAEF /* Debug */ = { 289 | isa = XCBuildConfiguration; 290 | buildSettings = { 291 | ALWAYS_SEARCH_USER_PATHS = NO; 292 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 293 | CLANG_CXX_LIBRARY = "libc++"; 294 | CLANG_ENABLE_MODULES = YES; 295 | CLANG_ENABLE_OBJC_ARC = YES; 296 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 297 | CLANG_WARN_BOOL_CONVERSION = YES; 298 | CLANG_WARN_COMMA = YES; 299 | CLANG_WARN_CONSTANT_CONVERSION = YES; 300 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 301 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 302 | CLANG_WARN_EMPTY_BODY = YES; 303 | CLANG_WARN_ENUM_CONVERSION = YES; 304 | CLANG_WARN_INFINITE_RECURSION = YES; 305 | CLANG_WARN_INT_CONVERSION = YES; 306 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 307 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 308 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 309 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 310 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 311 | CLANG_WARN_STRICT_PROTOTYPES = YES; 312 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 313 | CLANG_WARN_UNREACHABLE_CODE = YES; 314 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 315 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 316 | COPY_PHASE_STRIP = NO; 317 | CURRENT_PROJECT_VERSION = 1; 318 | DEBUG_INFORMATION_FORMAT = dwarf; 319 | ENABLE_STRICT_OBJC_MSGSEND = YES; 320 | ENABLE_TESTABILITY = YES; 321 | GCC_C_LANGUAGE_STANDARD = gnu99; 322 | GCC_DYNAMIC_NO_PIC = NO; 323 | GCC_NO_COMMON_BLOCKS = YES; 324 | GCC_OPTIMIZATION_LEVEL = 0; 325 | GCC_PREPROCESSOR_DEFINITIONS = ( 326 | "DEBUG=1", 327 | "$(inherited)", 328 | ); 329 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 330 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 331 | GCC_WARN_UNDECLARED_SELECTOR = YES; 332 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 333 | GCC_WARN_UNUSED_FUNCTION = YES; 334 | GCC_WARN_UNUSED_VARIABLE = YES; 335 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 336 | MTL_ENABLE_DEBUG_INFO = YES; 337 | ONLY_ACTIVE_ARCH = YES; 338 | SDKROOT = iphoneos; 339 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 340 | TARGETED_DEVICE_FAMILY = "1,2"; 341 | VERSIONING_SYSTEM = "apple-generic"; 342 | VERSION_INFO_PREFIX = ""; 343 | }; 344 | name = Debug; 345 | }; 346 | 9188C77C1C72D9D0004FFAEF /* Release */ = { 347 | isa = XCBuildConfiguration; 348 | buildSettings = { 349 | ALWAYS_SEARCH_USER_PATHS = NO; 350 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 351 | CLANG_CXX_LIBRARY = "libc++"; 352 | CLANG_ENABLE_MODULES = YES; 353 | CLANG_ENABLE_OBJC_ARC = YES; 354 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 355 | CLANG_WARN_BOOL_CONVERSION = YES; 356 | CLANG_WARN_COMMA = YES; 357 | CLANG_WARN_CONSTANT_CONVERSION = YES; 358 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 359 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 360 | CLANG_WARN_EMPTY_BODY = YES; 361 | CLANG_WARN_ENUM_CONVERSION = YES; 362 | CLANG_WARN_INFINITE_RECURSION = YES; 363 | CLANG_WARN_INT_CONVERSION = YES; 364 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 365 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 366 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 367 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 368 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 369 | CLANG_WARN_STRICT_PROTOTYPES = YES; 370 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 371 | CLANG_WARN_UNREACHABLE_CODE = YES; 372 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 373 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 374 | COPY_PHASE_STRIP = NO; 375 | CURRENT_PROJECT_VERSION = 1; 376 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 377 | ENABLE_NS_ASSERTIONS = NO; 378 | ENABLE_STRICT_OBJC_MSGSEND = YES; 379 | GCC_C_LANGUAGE_STANDARD = gnu99; 380 | GCC_NO_COMMON_BLOCKS = YES; 381 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 382 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 383 | GCC_WARN_UNDECLARED_SELECTOR = YES; 384 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 385 | GCC_WARN_UNUSED_FUNCTION = YES; 386 | GCC_WARN_UNUSED_VARIABLE = YES; 387 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 388 | MTL_ENABLE_DEBUG_INFO = NO; 389 | SDKROOT = iphoneos; 390 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 391 | TARGETED_DEVICE_FAMILY = "1,2"; 392 | VALIDATE_PRODUCT = YES; 393 | VERSIONING_SYSTEM = "apple-generic"; 394 | VERSION_INFO_PREFIX = ""; 395 | }; 396 | name = Release; 397 | }; 398 | 9188C77E1C72D9D0004FFAEF /* Debug */ = { 399 | isa = XCBuildConfiguration; 400 | buildSettings = { 401 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; 402 | DEFINES_MODULE = YES; 403 | DYLIB_COMPATIBILITY_VERSION = 1; 404 | DYLIB_CURRENT_VERSION = 1; 405 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 406 | INFOPLIST_FILE = ViewPagerController/Info.plist; 407 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 408 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 409 | PRODUCT_BUNDLE_IDENTIFIER = xxxAIRINxxx.ViewPagerController; 410 | PRODUCT_NAME = "$(TARGET_NAME)"; 411 | SKIP_INSTALL = YES; 412 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 413 | SWIFT_VERSION = 4.0; 414 | }; 415 | name = Debug; 416 | }; 417 | 9188C77F1C72D9D0004FFAEF /* Release */ = { 418 | isa = XCBuildConfiguration; 419 | buildSettings = { 420 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; 421 | DEFINES_MODULE = YES; 422 | DYLIB_COMPATIBILITY_VERSION = 1; 423 | DYLIB_CURRENT_VERSION = 1; 424 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 425 | INFOPLIST_FILE = ViewPagerController/Info.plist; 426 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 427 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 428 | PRODUCT_BUNDLE_IDENTIFIER = xxxAIRINxxx.ViewPagerController; 429 | PRODUCT_NAME = "$(TARGET_NAME)"; 430 | SKIP_INSTALL = YES; 431 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 432 | SWIFT_VERSION = 4.0; 433 | }; 434 | name = Release; 435 | }; 436 | 9188C7811C72D9D0004FFAEF /* Debug */ = { 437 | isa = XCBuildConfiguration; 438 | buildSettings = { 439 | INFOPLIST_FILE = ViewPagerControllerTests/Info.plist; 440 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 441 | PRODUCT_BUNDLE_IDENTIFIER = xxxAIRINxxx.ViewPagerControllerTests; 442 | PRODUCT_NAME = "$(TARGET_NAME)"; 443 | SWIFT_VERSION = 4.0; 444 | }; 445 | name = Debug; 446 | }; 447 | 9188C7821C72D9D0004FFAEF /* Release */ = { 448 | isa = XCBuildConfiguration; 449 | buildSettings = { 450 | INFOPLIST_FILE = ViewPagerControllerTests/Info.plist; 451 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 452 | PRODUCT_BUNDLE_IDENTIFIER = xxxAIRINxxx.ViewPagerControllerTests; 453 | PRODUCT_NAME = "$(TARGET_NAME)"; 454 | SWIFT_VERSION = 4.0; 455 | }; 456 | name = Release; 457 | }; 458 | /* End XCBuildConfiguration section */ 459 | 460 | /* Begin XCConfigurationList section */ 461 | 9188C7631C72D9CF004FFAEF /* Build configuration list for PBXProject "ViewPagerController" */ = { 462 | isa = XCConfigurationList; 463 | buildConfigurations = ( 464 | 9188C77B1C72D9D0004FFAEF /* Debug */, 465 | 9188C77C1C72D9D0004FFAEF /* Release */, 466 | ); 467 | defaultConfigurationIsVisible = 0; 468 | defaultConfigurationName = Release; 469 | }; 470 | 9188C77D1C72D9D0004FFAEF /* Build configuration list for PBXNativeTarget "ViewPagerController" */ = { 471 | isa = XCConfigurationList; 472 | buildConfigurations = ( 473 | 9188C77E1C72D9D0004FFAEF /* Debug */, 474 | 9188C77F1C72D9D0004FFAEF /* Release */, 475 | ); 476 | defaultConfigurationIsVisible = 0; 477 | defaultConfigurationName = Release; 478 | }; 479 | 9188C7801C72D9D0004FFAEF /* Build configuration list for PBXNativeTarget "ViewPagerControllerTests" */ = { 480 | isa = XCConfigurationList; 481 | buildConfigurations = ( 482 | 9188C7811C72D9D0004FFAEF /* Debug */, 483 | 9188C7821C72D9D0004FFAEF /* Release */, 484 | ); 485 | defaultConfigurationIsVisible = 0; 486 | defaultConfigurationName = Release; 487 | }; 488 | /* End XCConfigurationList section */ 489 | }; 490 | rootObject = 9188C7601C72D9CF004FFAEF /* Project object */; 491 | } 492 | -------------------------------------------------------------------------------- /Proj/ViewPagerController.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Proj/ViewPagerController.xcodeproj/xcshareddata/xcschemes/ViewPagerController.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 53 | 54 | 64 | 65 | 71 | 72 | 73 | 74 | 75 | 76 | 82 | 83 | 89 | 90 | 91 | 92 | 94 | 95 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /Proj/ViewPagerController.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Proj/ViewPagerController.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Proj/ViewPagerController/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 | FMWK 17 | CFBundleShortVersionString 18 | 2.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Proj/ViewPagerController/ViewPagerController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewPagerController.h 3 | // ViewPagerController 4 | // 5 | // Created by xxxAIRINxxx on 2016/02/16. 6 | // Copyright © 2016 xxxAIRINxxx. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for ViewPagerController. 12 | FOUNDATION_EXPORT double ViewPagerControllerVersionNumber; 13 | 14 | //! Project version string for ViewPagerController. 15 | FOUNDATION_EXPORT const unsigned char ViewPagerControllerVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /Proj/ViewPagerControllerTests/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 | -------------------------------------------------------------------------------- /Proj/ViewPagerControllerTests/ViewPagerControllerTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewPagerControllerTests.swift 3 | // ViewPagerControllerTests 4 | // 5 | // Created by xxxAIRINxxx on 2016/02/16. 6 | // Copyright © 2016 xxxAIRINxxx. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import ViewPagerController 11 | 12 | class ViewPagerControllerTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | // Use XCTAssert and related functions to verify your tests produce the correct results. 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measureBlock { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ViewPagerController 2 | 3 | [![Swift 4.1](https://img.shields.io/badge/Swift-4.1-orange.svg?style=flat)](https://developer.apple.com/swift/) 4 | [![Platforms iOS](https://img.shields.io/badge/Platforms-iOS-lightgray.svg?style=flat)](https://developer.apple.com/swift/) 5 | [![Xcode 9.3+](https://img.shields.io/badge/Xcode-9.3+-blue.svg?style=flat)](https://developer.apple.com/swift/) 6 | 7 | ![capture1](capture1.gif "capture1") 8 | 9 | ![capture2](capture2.gif "capture2") 10 | 11 | ## Features 12 | 13 | - Show header tab menu 14 | - Infinite scroll header tab menu 15 | - Infinite scroll contents view 16 | - Can add header view 17 | - Show header tab selected view (customizeable) 18 | - Can scroll header view or navigation bar (customizeable) 19 | 20 | ## Demo 21 | 22 | [See demo on Appetize.io](https://appetize.io/app/gbtduh7bghgt397t0e8hedd9wm?device=iphone5s&scale=75&orientation=portrait&osVersion=9.2) 23 | 24 | ## Requirements 25 | 26 | * Xcode 9.3+ 27 | * iPhone Portrait (iPad Not Supported) 28 | 29 | | | OS | Swift | 30 | |------------|------------------|--------------| 31 | | **v1.3.0** | iOS 8+ | 3.0 | 32 | | **v2.0.x** | iOS 9+ | 4.1 | 33 | 34 | 35 | ## Installation 36 | 37 | ### CocoaPods 38 | 39 | ViewPagerController is available through [CocoaPods](http://cocoapods.org). To install 40 | it, simply add the following line to your Podfile: 41 | 42 | ```ruby 43 | use_frameworks! 44 | 45 | pod "ViewPagerController" 46 | ``` 47 | 48 | ### Carthage 49 | 50 | To integrate ViewPagerController into your Xcode project using Carthage, specify it in your Cartfile: 51 | 52 | ```ruby 53 | github "xxxAIRINxxx/ViewPagerController" 54 | ``` 55 | 56 | ## License 57 | 58 | MIT license. See the LICENSE file for more info. 59 | -------------------------------------------------------------------------------- /Sources/InfiniteScrollView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // InfiniteScrollView.swift 3 | // ViewPagerController 4 | // 5 | // Created by xxxAIRINxxx on 2016/01/05. 6 | // Copyright © 2016 xxxAIRINxxx. All rights reserved. 7 | // 8 | // @see : https://github.com/bteapot/BTInfiniteScrollView 9 | 10 | import Foundation 11 | import UIKit 12 | 13 | public enum XPosition: Int { 14 | case start 15 | case middle 16 | case end 17 | } 18 | 19 | public struct InfiniteItem { 20 | let index : Int 21 | let thickness : CGFloat 22 | let view : UIView 23 | 24 | public init(_ index: Int, _ thickness: CGFloat, _ view: UIView) { 25 | self.index = index 26 | self.thickness = thickness 27 | self.view = view 28 | } 29 | } 30 | 31 | public protocol InfiniteScrollViewDataSource: class { 32 | 33 | func totalItemCount() -> Int 34 | 35 | func viewForIndex(_ index: Int) -> UIView 36 | 37 | func thicknessForIndex(_ index: Int) -> CGFloat 38 | } 39 | 40 | public protocol InfiniteScrollViewDelegate: class { 41 | 42 | func updateContentOffset(_ delta: CGFloat) 43 | 44 | func infiniteScrollViewWillBeginDecelerating(_ scrollView: UIScrollView) 45 | 46 | func infiniteScrollViewWillBeginDragging(_ scrollView: UIScrollView) 47 | 48 | func infinitScrollViewDidScroll(_ scrollView: UIScrollView) 49 | 50 | func infiniteScrollViewDidEndCenterScrolling(_ item: InfiniteItem) 51 | 52 | func infiniteScrollViewDidShowCenterItem(_ item: InfiniteItem) 53 | } 54 | 55 | public final class InfiniteScrollView: UIScrollView { 56 | 57 | public weak var infiniteDataSource : InfiniteScrollViewDataSource! 58 | public weak var infiniteDelegate : InfiniteScrollViewDelegate? 59 | 60 | public fileprivate(set) var items : [InfiniteItem] = [] 61 | 62 | public var scrolling : Int = 0 63 | fileprivate var lastReportedItemIndex : Int = Int.min 64 | fileprivate var isUserScrolling = false 65 | 66 | // MARK: - Constructor 67 | 68 | override init(frame: CGRect) { 69 | super.init(frame: frame) 70 | self.commonInit() 71 | } 72 | 73 | required public init?(coder aDecoder: NSCoder) { 74 | super.init(coder: aDecoder) 75 | self.commonInit() 76 | } 77 | 78 | fileprivate func commonInit() { 79 | self.delegate = self 80 | self.autoresizesSubviews = false 81 | self.bounces = false 82 | self.showsHorizontalScrollIndicator = false 83 | self.panGestureRecognizer.maximumNumberOfTouches = 1 84 | } 85 | 86 | // MARK: - Override 87 | 88 | override public var frame: CGRect { 89 | get { return super.frame } 90 | set { 91 | if newValue.isEmpty { return } 92 | 93 | let bounds = self.bounds 94 | let oldVisibleCenterX = bounds.origin.x + bounds.size.width / 2.0 95 | 96 | super.frame = newValue 97 | 98 | let newBounds = self.bounds 99 | if newBounds.size.width * 5 > self.contentSize.width || newBounds.size.height < self.contentSize.height { 100 | super.contentSize = CGSize(width: newBounds.width * 5, height: newBounds.size.height) 101 | } 102 | 103 | let newVisibleCenterX = newBounds.origin.x + newBounds.size.width / 2.0 104 | let deltaX = oldVisibleCenterX - newVisibleCenterX 105 | 106 | self.items = self.items.map(){ item in 107 | item.view.frame.origin.x = item.view.frame.origin.x - deltaX 108 | item.view.frame.size.height = newBounds.size.height 109 | return item 110 | } 111 | } 112 | } 113 | 114 | public override func layoutSubviews() { 115 | super.layoutSubviews() 116 | guard self.infiniteDataSource.totalItemCount() > 0 else { return } 117 | 118 | var bounds = self.bounds 119 | let visible = bounds.size.width 120 | 121 | if self.scrolling == 0 { 122 | var delta = self.contentSize.width / 2 - bounds.midX 123 | let allow = self.isPagingEnabled ? !self.isDecelerating : true 124 | 125 | if allow && fabs(delta) > visible { 126 | delta = visible * (delta > 0 ? 1 : -1) 127 | 128 | self.delegate = nil 129 | 130 | let contentOffset = self.contentOffset 131 | self.contentOffset = CGPoint(x: contentOffset.x + delta, y: contentOffset.y) 132 | 133 | self.delegate = self 134 | 135 | bounds = self.bounds 136 | 137 | self.items = self.items.map(){ item in 138 | item.view.frame.origin.x += delta 139 | return item 140 | } 141 | self.infiniteDelegate?.updateContentOffset(delta) 142 | } 143 | } 144 | 145 | let minVisible = bounds.minX 146 | let maxVisible = bounds.maxX 147 | 148 | let lastItem = self.items.last 149 | var index = 0 150 | var endEdge: CGFloat = 0 151 | 152 | if let _item = lastItem { 153 | index = _item.index 154 | endEdge = _item.view.frame.maxX 155 | } else { 156 | endEdge = self.placeNewItem(.middle, edge: 0, index: 0) 157 | } 158 | 159 | while (endEdge < maxVisible) { 160 | index += 1 161 | endEdge = self.placeNewItem(.end, edge: endEdge, index: index) 162 | } 163 | 164 | let firstItem = self.items.first 165 | var startEdge: CGFloat = 0 166 | 167 | if let _item = firstItem { 168 | index = _item.index 169 | startEdge = _item.view.frame.minX 170 | } 171 | 172 | while (startEdge > minVisible) { 173 | index -= 1 174 | startEdge = self.placeNewItem(.start, edge: startEdge, index: index) 175 | } 176 | 177 | if self.scrolling == 0 && self.items.count > 0 { 178 | var lasted = self.items.last 179 | while (lasted != nil && lasted!.view.frame.minX >= maxVisible) { 180 | lasted!.view.removeFromSuperview() 181 | self.items.removeLast() 182 | lasted = self.items.last 183 | } 184 | 185 | var firsted = self.items.first 186 | while (firsted != nil && firsted!.view.frame.maxX <= minVisible) { 187 | firsted!.view.removeFromSuperview() 188 | self.items.remove(at: 0) 189 | firsted = self.items.first 190 | } 191 | } 192 | 193 | if let _item = self.itemAtCenterPosition() { 194 | if self.isUserScrolling { return } 195 | if self.lastReportedItemIndex != _item.index { 196 | self.lastReportedItemIndex = _item.index 197 | self.infiniteDelegate?.infiniteScrollViewDidShowCenterItem(_item) 198 | } 199 | } 200 | } 201 | 202 | // MARK: - Public Functions 203 | 204 | public func itemAtView(_ view: UIView) -> InfiniteItem? { 205 | return self.items.filter() { item in return item.view === view }.first 206 | } 207 | 208 | public func itemAtIndex(_ index: Int) -> InfiniteItem? { 209 | return self.items.filter() { item in return item.index == index }.first 210 | } 211 | 212 | public func updateItems(_ handler: ((InfiniteItem) -> InfiniteItem)) { 213 | self.items = self.items.map(handler) 214 | } 215 | 216 | public func reset() { 217 | self.subviews.forEach() { $0.removeFromSuperview() } 218 | self.items.removeAll(keepingCapacity: true) 219 | } 220 | 221 | public func reloadViews() { 222 | guard self.infiniteDataSource.totalItemCount() > 0 else { return } 223 | 224 | if let _targetItem = self.itemAtCenterPosition() { 225 | self.reloadView(.start, item: _targetItem, edge: _targetItem.view.frame.midX) 226 | 227 | var previousItem = _targetItem 228 | var item = self.itemAtIndex(previousItem.index + 1) 229 | 230 | while (item != nil) { 231 | self.reloadView(.end, item: item!, edge: previousItem.view.frame.maxX) 232 | previousItem = item! 233 | item = self.itemAtIndex(previousItem.index + 1) 234 | } 235 | 236 | previousItem = _targetItem 237 | item = self.itemAtIndex(previousItem.index - 1) 238 | 239 | while (item != nil) { 240 | self.reloadView(.end, item: item!, edge: previousItem.view.frame.maxX) 241 | previousItem = item! 242 | item = self.itemAtIndex(previousItem.index - 1) 243 | } 244 | 245 | self.setNeedsLayout() 246 | self.layoutIfNeeded() 247 | } 248 | } 249 | 250 | public func reloadView(_ position: XPosition, item: InfiniteItem, edge: CGFloat) { 251 | guard self.infiniteDataSource.totalItemCount() > 0 else { return } 252 | 253 | let convertIndex = self.convertIndex(item.index) 254 | let bounds = self.bounds 255 | let thickness = CGFloat(ceilf(Float(self.infiniteDataSource.thicknessForIndex(convertIndex)))) 256 | let view = (self.infiniteDataSource.viewForIndex(convertIndex)) 257 | 258 | switch position { 259 | case .start: 260 | item.view.frame = CGRect(x: edge - thickness, y: 0, width: thickness, height: bounds.size.height) 261 | case .middle: 262 | item.view.frame = CGRect(x: edge - thickness / 2.0, y: 0, width: thickness, height: bounds.size.height) 263 | case .end: 264 | item.view.frame = CGRect(x: edge, y: 0, width: thickness, height: bounds.size.height) 265 | } 266 | 267 | item.view.removeFromSuperview() 268 | self.addSubview(view) 269 | } 270 | 271 | public func resetWithIndex(_ index: Int) { 272 | guard self.infiniteDataSource.totalItemCount() > 0 else { return } 273 | if self.bounds.isEmpty { return } 274 | 275 | self.reset() 276 | _ = self.placeNewItem(.middle, edge: 0, index: index) 277 | self.setNeedsLayout() 278 | self.layoutIfNeeded() 279 | } 280 | 281 | public func itemAtCenterPosition() -> InfiniteItem? { 282 | let bounds = self.bounds 283 | let mark: CGFloat = bounds.midX 284 | for item in self.items { 285 | if item.view.frame.minX <= mark && item.view.frame.maxX >= mark { 286 | return item 287 | } 288 | } 289 | return nil 290 | } 291 | 292 | public func scrollToCenter(_ index: Int, offset: CGFloat, animated: Bool, animation: (() -> Void)?, completion: (() -> Void)?) { 293 | guard self.infiniteDataSource.totalItemCount() > 0 else { return } 294 | if self.bounds.isEmpty { return } 295 | 296 | self.setNeedsLayout() 297 | self.layoutIfNeeded() 298 | 299 | var bounds = self.bounds 300 | let visible = bounds.size.width 301 | 302 | var targetItem = self.items.filter({item in return item.index == index }).first 303 | 304 | if targetItem == nil { 305 | let firstItem = self.items.first 306 | let lastItem = self.items.last 307 | let isStart = index < firstItem!.index 308 | targetItem = self.createItem(index) 309 | var newItems: [InfiniteItem] = [] 310 | newItems.append(targetItem!) 311 | 312 | var gap: CGFloat = isStart ? (visible - targetItem!.thickness) / 2.0 + offset : (visible - targetItem!.thickness) / 2.0 - offset 313 | 314 | var indexDelta = (isStart ? firstItem!.index - index : index - lastItem!.index) - 1 315 | var gapItemIndex = index 316 | 317 | while (indexDelta > 0 && gap >= 0) { 318 | gapItemIndex += isStart ? 1 : -1 319 | let item = self.createItem(gapItemIndex) 320 | 321 | isStart ? newItems.append(item) : newItems.insert(item, at: 0) 322 | 323 | gap -= item.thickness 324 | indexDelta -= 1 325 | } 326 | 327 | if isStart { 328 | var startEdge = firstItem!.view.frame.minX 329 | var newItemIndex = newItems.count - 1 330 | while newItemIndex >= 0 { 331 | let item = newItems[newItemIndex] 332 | item.view.frame = CGRect(x: startEdge - item.thickness, y: 0, width: item.thickness, height: bounds.size.height) 333 | startEdge = item.view.frame.minX 334 | self.addSubview(item.view) 335 | self.items.insert(item, at: 0) 336 | 337 | newItemIndex -= 1 338 | } 339 | } else { 340 | var endEdge = firstItem!.view.frame.maxX 341 | self.items = newItems.map() { item in 342 | item.view.frame = CGRect(x: endEdge, y: 0, width: item.thickness, height: bounds.size.height) 343 | endEdge = item.view.frame.maxX 344 | self.addSubview(item.view) 345 | return item 346 | } 347 | } 348 | } 349 | 350 | bounds = CGRect( 351 | x: targetItem!.view.frame.minX - (bounds.size.width - targetItem!.thickness) / 2.0 + offset, 352 | y: 0, 353 | width: bounds.size.width, 354 | height: bounds.size.height 355 | ) 356 | 357 | self.scrolling += 1 358 | self.setContentOffset(self.contentOffset, animated: false) 359 | 360 | if animated { 361 | UIView.animateKeyframes(withDuration: 0.25, delay: 0, options: .beginFromCurrentState, animations: { 362 | self.bounds = bounds 363 | animation?() 364 | }, completion: { finished in 365 | self.scrolling -= 1 366 | self.setNeedsLayout() 367 | self.layoutIfNeeded() 368 | completion?() 369 | }) 370 | } else { 371 | self.bounds = bounds 372 | self.scrolling -= 1 373 | completion?() 374 | } 375 | } 376 | 377 | public func scrollToCenter(_ index: Int, animated: Bool, animation: (() -> Void)?, completion: (() -> Void)?) { 378 | self.scrollToCenter(index, offset: 0, animated: animated, animation: animation, completion: completion) 379 | } 380 | 381 | public func convertIndex(_ scrollViewIndex: Int) -> Int { 382 | let total = self.infiniteDataSource.totalItemCount() 383 | let currentIndex = scrollViewIndex >= 0 ? (scrollViewIndex % total) : (total - (-scrollViewIndex % total)) 384 | 385 | return currentIndex == total ? 0 : currentIndex 386 | } 387 | 388 | // MARK: - Private Functions 389 | 390 | fileprivate func createItem(_ index: Int) -> InfiniteItem { 391 | let convertIndex = self.convertIndex(index) 392 | let bounds = self.bounds 393 | let thickness = CGFloat(ceilf(Float(self.infiniteDataSource.thicknessForIndex(convertIndex)))) 394 | let view = self.infiniteDataSource.viewForIndex(convertIndex) 395 | 396 | view.frame = CGRect(x: 0, y: 0, width: thickness, height: bounds.size.height) 397 | 398 | return InfiniteItem(index, thickness, view) 399 | } 400 | 401 | fileprivate func placeNewItem(_ position: XPosition, edge: CGFloat, index: Int) -> CGFloat { 402 | let item = self.createItem(index) 403 | 404 | switch position { 405 | case .start: 406 | item.view.frame.origin.x = edge - item.thickness 407 | self.addSubview(item.view) 408 | self.items.insert(item, at: 0) 409 | return item.view.frame.minX 410 | case .middle: 411 | item.view.frame.origin.x = bounds.origin.x + (bounds.size.width - item.thickness) / 2.0 412 | self.addSubview(item.view) 413 | self.items.append(item) 414 | return item.view.frame.maxX 415 | case .end: 416 | item.view.frame.origin.x = edge 417 | self.addSubview(item.view) 418 | self.items.append(item) 419 | return item.view.frame.maxX 420 | } 421 | } 422 | } 423 | 424 | // MARK: - Private UIScrollViewDelegate 425 | 426 | extension InfiniteScrollView: UIScrollViewDelegate { 427 | 428 | public func scrollViewWillBeginDecelerating(_ scrollView: UIScrollView) { 429 | self.infiniteDelegate?.infiniteScrollViewWillBeginDecelerating(scrollView) 430 | } 431 | 432 | public func scrollViewWillBeginDragging(_ scrollView: UIScrollView) { 433 | self.infiniteDelegate?.infiniteScrollViewWillBeginDragging(scrollView) 434 | self.isUserScrolling = true 435 | } 436 | 437 | public func scrollViewDidScroll(_ scrollView: UIScrollView) { 438 | self.infiniteDelegate?.infinitScrollViewDidScroll(scrollView) 439 | } 440 | 441 | public func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) { 442 | self.isUserScrolling = false 443 | 444 | if let _targetItem = self.itemAtCenterPosition() { 445 | self.scrollToCenter(_targetItem.index, offset: 0, animated: true, animation: nil, completion: nil) 446 | self.infiniteDelegate?.infiniteScrollViewDidEndCenterScrolling(_targetItem) 447 | } 448 | } 449 | 450 | public func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) { 451 | if decelerate { return } 452 | self.isUserScrolling = false 453 | 454 | if let _targetItem = self.itemAtCenterPosition() { 455 | self.scrollToCenter(_targetItem.index, offset: 0, animated: true, animation: nil, completion: nil) 456 | self.infiniteDelegate?.infiniteScrollViewDidEndCenterScrolling(_targetItem) 457 | } 458 | } 459 | } 460 | -------------------------------------------------------------------------------- /Sources/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 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Sources/PagerContainerView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PagerContainerView.swift 3 | // ViewPagerController 4 | // 5 | // Created by xxxAIRINxxx on 2016/01/05. 6 | // Copyright © 2016 xxxAIRINxxx. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | fileprivate func < (lhs: T?, rhs: T?) -> Bool { 12 | switch (lhs, rhs) { 13 | case let (l?, r?): 14 | return l < r 15 | case (nil, _?): 16 | return true 17 | default: 18 | return false 19 | } 20 | } 21 | 22 | fileprivate func > (lhs: T?, rhs: T?) -> Bool { 23 | switch (lhs, rhs) { 24 | case let (l?, r?): 25 | return l > r 26 | default: 27 | return rhs < lhs 28 | } 29 | } 30 | 31 | 32 | public final class PagerContainerView: UIView { 33 | 34 | // MARK: - Public Handler Properties 35 | 36 | public var didShowViewControllerHandler : ((UIViewController) -> Void)? 37 | 38 | public var startSyncHandler : ((Int) -> Void)? 39 | 40 | public var syncOffsetHandler : ((_ currentIndex: Int, _ percentComplete: CGFloat, _ scrollingTowards: Bool) -> Void)? 41 | 42 | public var finishSyncHandler : ((Int) -> Void)? 43 | 44 | // MARK: - Private Properties 45 | 46 | fileprivate lazy var scrollView : InfiniteScrollView = { 47 | var scrollView = InfiniteScrollView(frame: self.bounds) 48 | scrollView.infiniteDataSource = self 49 | scrollView.infiniteDelegate = self 50 | scrollView.backgroundColor = UIColor.clear 51 | return scrollView 52 | }() 53 | 54 | // Contents 55 | fileprivate var contents : [UIViewController] = [] 56 | 57 | // Sync ContainerView Scrolling 58 | public var scrollingIncrementalRatio: CGFloat = 1.1 59 | fileprivate var startDraggingOffsetX : CGFloat? 60 | fileprivate var startDraggingIndex : Int? 61 | 62 | // MARK: - Constructor 63 | 64 | public override init(frame: CGRect) { 65 | super.init(frame: frame) 66 | self.commonInit() 67 | } 68 | 69 | required public init?(coder aDecoder: NSCoder) { 70 | super.init(coder: aDecoder) 71 | self.commonInit() 72 | } 73 | 74 | fileprivate func commonInit() { 75 | self.addSubview(self.scrollView) 76 | self.scrollView.isPagingEnabled = true 77 | self.scrollView.scrollsToTop = false 78 | 79 | self.setupConstraint() 80 | } 81 | 82 | // MARK: - Override 83 | 84 | override public func layoutSubviews() { 85 | super.layoutSubviews() 86 | self.scrollView.frame = self.bounds 87 | } 88 | 89 | // MARK: - Public Functions 90 | 91 | public func addViewController(_ viewController: UIViewController) { 92 | self.contents.append(viewController) 93 | self.scrollView.reloadViews() 94 | } 95 | 96 | public func indexFromViewController(_ viewController: UIViewController) -> Int? { 97 | return self.contents.index(of: viewController) 98 | } 99 | 100 | public func removeContent(_ viewController: UIViewController) { 101 | if let content = self.contents.filter({ $0 === viewController }).first { 102 | self.contents = self.contents.filter() { $0 !== content } 103 | self.scrollView.reset() 104 | self.reload() 105 | } 106 | } 107 | 108 | public func scrollToCenter(_ index: Int, animated: Bool, animation: (() -> Void)?, completion: (() -> Void)?) { 109 | if !self.scrollView.isDragging { 110 | let _index = self.currentIndex() 111 | if _index == index { return } 112 | if _index > index { 113 | self.scrollView.resetWithIndex(index + 1) 114 | } else { 115 | self.scrollView.resetWithIndex(index - 1) 116 | } 117 | self.scrollView.scrollToCenter(index, animated: animated, animation: animation) { [weak self] in 118 | self?.scrollView.resetWithIndex(index) 119 | completion?() 120 | } 121 | } 122 | } 123 | 124 | public func currentIndex() -> Int? { 125 | guard let currentItem = self.scrollView.itemAtCenterPosition() else { return nil } 126 | return currentItem.index 127 | } 128 | 129 | public func reload() { 130 | self.scrollView.resetWithIndex(0) 131 | } 132 | 133 | public func currentContent() -> UIViewController? { 134 | guard let _index = self.currentIndex() , _index != Int.min else { return nil } 135 | 136 | return self.contents[self.scrollView.convertIndex(_index)] 137 | } 138 | } 139 | 140 | // MARK: - Layout 141 | 142 | extension PagerContainerView { 143 | 144 | fileprivate func setupConstraint() { 145 | self.allPin(self.scrollView) 146 | } 147 | } 148 | 149 | // MARK: - Sync ContainerView Scrolling 150 | 151 | extension PagerContainerView { 152 | 153 | fileprivate func finishSyncViewScroll(_ index: Int) { 154 | self.finishSyncHandler?(index) 155 | self.startDraggingOffsetX = nil 156 | self.scrollView.setNeedsLayout() 157 | self.scrollView.layoutIfNeeded() 158 | } 159 | } 160 | 161 | // MARK: - InfiniteScrollViewDataSource 162 | 163 | extension PagerContainerView: InfiniteScrollViewDataSource { 164 | 165 | public func totalItemCount() -> Int { 166 | return self.contents.count 167 | } 168 | 169 | public func viewForIndex(_ index: Int) -> UIView { 170 | let controller = self.contents[index] 171 | return controller.view 172 | } 173 | 174 | public func thicknessForIndex(_ index: Int) -> CGFloat { 175 | return self.frame.size.width 176 | } 177 | } 178 | 179 | // MARK: - InfiniteScrollViewDelegate 180 | 181 | extension PagerContainerView: InfiniteScrollViewDelegate { 182 | 183 | public func updateContentOffset(_ delta: CGFloat) { 184 | self.startDraggingOffsetX? += delta 185 | } 186 | 187 | public func infiniteScrollViewWillBeginDecelerating(_ scrollView: UIScrollView) {} 188 | 189 | public func infiniteScrollViewWillBeginDragging(_ scrollView: UIScrollView) { 190 | if let _currentItem = self.scrollView.itemAtCenterPosition() { 191 | if self.startDraggingOffsetX == nil { 192 | self.startSyncHandler?(_currentItem.index) 193 | } else { 194 | self.finishSyncViewScroll(_currentItem.index) 195 | } 196 | } 197 | } 198 | 199 | public func infinitScrollViewDidScroll(_ scrollView: UIScrollView) { 200 | if let _startDraggingOffsetX = self.startDraggingOffsetX { 201 | let offsetX = scrollView.contentOffset.x 202 | let scrollingTowards = _startDraggingOffsetX > offsetX 203 | let percent = (offsetX - _startDraggingOffsetX) / scrollView.bounds.width * self.scrollingIncrementalRatio 204 | let percentComplete = scrollingTowards == false ? percent : (1.0 - percent) - 1.0 205 | let _percentComplete = min(1.0, percentComplete) 206 | 207 | if let _currentItem = self.scrollView.itemAtCenterPosition() { 208 | self.syncOffsetHandler?(_currentItem.index, _percentComplete, scrollingTowards) 209 | } 210 | } else { 211 | if scrollView.isDragging { 212 | self.startDraggingOffsetX = ceil(scrollView.contentOffset.x) 213 | } 214 | } 215 | } 216 | 217 | public func infiniteScrollViewDidEndCenterScrolling(_ item: InfiniteItem) { 218 | guard self.startDraggingOffsetX != nil else { return } 219 | 220 | if let _currentItem = self.scrollView.itemAtCenterPosition() { 221 | self.scrollView.scrollToCenter(_currentItem.index, animated: false, animation: nil, completion: nil) 222 | self.finishSyncViewScroll(_currentItem.index) 223 | } 224 | } 225 | 226 | public func infiniteScrollViewDidShowCenterItem(_ item: InfiniteItem) { 227 | guard let controller = self.contents.filter({ $0.view === item.view }).first else { return } 228 | self.didShowViewControllerHandler?(controller) 229 | } 230 | } 231 | -------------------------------------------------------------------------------- /Sources/PagerTabMenuView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PagerTabMenuView.swift 3 | // ViewPagerController 4 | // 5 | // Created by xxxAIRINxxx on 2016/01/05. 6 | // Copyright © 2016 xxxAIRINxxx. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | public final class PagerTabMenuView: UIView { 13 | 14 | // MARK: - Public Handler Properties 15 | 16 | public var selectedIndexHandler : ((Int) -> Void)? 17 | 18 | public var updateSelectedViewHandler : ((UIView) -> Void)? 19 | 20 | public var willBeginScrollingHandler : ((UIView) -> Void)? 21 | 22 | public var didEndTabMenuScrollingHandler : ((UIView) -> Void)? 23 | 24 | // MARK: - Custom Settings Properties 25 | 26 | // Title Layout 27 | public fileprivate(set) var titleMargin : CGFloat = 0.0 28 | public fileprivate(set) var titleMinWidth : CGFloat = 0.0 29 | 30 | // Title Color 31 | public fileprivate(set) var defaultTitleColor : UIColor = UIColor.gray 32 | public fileprivate(set) var highlightedTitleColor : UIColor = UIColor.white 33 | public fileprivate(set) var selectedTitleColor : UIColor = UIColor.white 34 | 35 | // Title Font 36 | public fileprivate(set) var defaultTitleFont : UIFont = UIFont.systemFont(ofSize: 14) 37 | public fileprivate(set) var highlightedTitleFont : UIFont = UIFont.systemFont(ofSize: 14) 38 | public fileprivate(set) var selectedTitleFont : UIFont = UIFont.boldSystemFont(ofSize: 14) 39 | 40 | // Selected View 41 | public fileprivate(set) var selectedViewBackgroundColor : UIColor = UIColor.clear 42 | public fileprivate(set) var selectedViewInsets : UIEdgeInsets = UIEdgeInsets.zero 43 | 44 | // MARK: - Private Properties 45 | 46 | // Views 47 | fileprivate var selectedView : UIView = UIView(frame: CGRect.zero) 48 | fileprivate var backgroundView : UIView = UIView(frame: CGRect.zero) 49 | fileprivate lazy var scrollView : InfiniteScrollView = { 50 | var scrollView = InfiniteScrollView(frame: self.bounds) 51 | scrollView.infiniteDataSource = self 52 | scrollView.infiniteDelegate = self 53 | scrollView.scrollsToTop = false 54 | scrollView.backgroundColor = UIColor.clear 55 | return scrollView 56 | }() 57 | 58 | // Contents 59 | fileprivate var contents : [String] = [] 60 | 61 | // Selected View Layout 62 | fileprivate var selectedViewTopConstraint : NSLayoutConstraint! 63 | fileprivate var selectedViewBottomConstraint : NSLayoutConstraint! 64 | fileprivate var selectedViewWidthConstraint : NSLayoutConstraint! 65 | 66 | // Sync ContainerView Scrolling 67 | fileprivate var isSyncContainerViewScrolling : Bool = false 68 | fileprivate var syncStartIndex : Int = Int.min 69 | fileprivate var syncNextIndex : Int = Int.min 70 | fileprivate var syncStartContentOffsetX : CGFloat = CGFloat.leastNormalMagnitude 71 | fileprivate var syncContentOffsetXDistance : CGFloat = CGFloat.leastNormalMagnitude 72 | fileprivate var scrollingTowards : Bool = false 73 | fileprivate var percentComplete: CGFloat = CGFloat.leastNormalMagnitude 74 | 75 | // TODO : Workaround : min item infinite scroll 76 | 77 | fileprivate var useTitles : [String] = [] 78 | 79 | fileprivate var contentsRepeatCount : Int { 80 | get { 81 | let minWidth = self.bounds.size.width * 2 82 | let totalItemCount = self.totalItemCount() 83 | var totalItemWitdh: CGFloat = 0.0 84 | for index in 0.. UIView { 143 | return self.selectedView 144 | } 145 | 146 | public func updateAppearance(_ appearance: TabMenuAppearance) { 147 | self.backgroundColor = appearance.backgroundColor 148 | 149 | // Title Layout 150 | self.titleMargin = appearance.titleMargin 151 | self.titleMinWidth = appearance.titleMinWidth 152 | 153 | // Title Color 154 | self.defaultTitleColor = appearance.defaultTitleColor 155 | self.highlightedTitleColor = appearance.highlightedTitleColor 156 | self.selectedTitleColor = appearance.selectedTitleColor 157 | 158 | // Title Font 159 | self.defaultTitleFont = appearance.defaultTitleFont 160 | self.highlightedTitleFont = appearance.highlightedTitleFont 161 | self.selectedTitleFont = appearance.selectedTitleFont 162 | 163 | // Selected View 164 | self.selectedViewBackgroundColor = appearance.selectedViewBackgroundColor 165 | self.selectedView.backgroundColor = self.selectedViewBackgroundColor 166 | self.selectedViewInsets = appearance.selectedViewInsets 167 | 168 | self.backgroundView.subviews.forEach() { $0.removeFromSuperview() } 169 | if let _contentsView = appearance.backgroundContentsView { 170 | self.backgroundView.addSubview(_contentsView) 171 | self.backgroundView.allPin(_contentsView) 172 | } 173 | 174 | self.updateSelectedViewLayout(false) 175 | self.updateButtonAttribute() 176 | self.scrollView.reloadViews() 177 | } 178 | 179 | public func addTitle(_ title: String) { 180 | self.contents.append(title) 181 | self.reload() 182 | } 183 | 184 | public func removeContentAtIndex(_ index: Int) { 185 | self.contents.remove(at: index) 186 | self.reload() 187 | } 188 | 189 | public func scrollToCenter(_ index: Int, animated: Bool, animation: (() -> Void)?, completion: (() -> Void)?) { 190 | self.scrollView.scrollToCenter(index, animated: animated, animation: animation!, completion: completion!) 191 | } 192 | 193 | public func stopScrolling(_ index: Int) { 194 | self.scrollView.isScrollEnabled = false 195 | self.scrollView.setContentOffset(self.scrollView.contentOffset, animated: false) 196 | self.scrollView.isScrollEnabled = true 197 | self.scrollView.resetWithIndex(index) 198 | self.updateSelectedButton(index) 199 | } 200 | 201 | public func reload() { 202 | self.updateUseContens() 203 | self.scrollView.resetWithIndex(0) 204 | self.updateSelectedButton(0) 205 | self.updateSelectedViewLayout(false) 206 | } 207 | } 208 | 209 | // MARK: - Sync ContainerView Scrolling 210 | 211 | extension PagerTabMenuView { 212 | 213 | internal func syncContainerViewScrollTo(_ currentIndex: Int, percentComplete: CGFloat, scrollingTowards: Bool) { 214 | if self.isSyncContainerViewScrolling { 215 | self.scrollingTowards = scrollingTowards 216 | 217 | self.syncOffset(percentComplete) 218 | self.syncSelectedViewWidth(percentComplete) 219 | self.syncButtons(percentComplete) 220 | } else { 221 | self.scrollView.scrollToCenter(currentIndex, animated: false, animation: nil, completion: nil) 222 | if let _currentItem = self.scrollView.itemAtCenterPosition() { 223 | let nextItem = self.scrollView.itemAtIndex(_currentItem.index + (scrollingTowards ? -1 : 1)) 224 | 225 | if let _nextItem = nextItem { 226 | self.scrollView.isUserInteractionEnabled = false 227 | self.isSyncContainerViewScrolling = true 228 | self.syncStartIndex = _currentItem.index 229 | self.syncNextIndex = _nextItem.index 230 | self.syncStartContentOffsetX = self.scrollView.contentOffset.x 231 | let startOffsetX = _currentItem.view.frame.midX 232 | let endOffsetX = _nextItem.view.frame.midX 233 | self.scrollingTowards = scrollingTowards 234 | self.syncContentOffsetXDistance = scrollingTowards ? startOffsetX - endOffsetX : endOffsetX - startOffsetX 235 | } 236 | } 237 | } 238 | } 239 | 240 | internal func finishSyncContainerViewScroll(_ index: Int) { 241 | self.scrollView.isUserInteractionEnabled = true 242 | self.isSyncContainerViewScrolling = false 243 | self.percentComplete = CGFloat.leastNormalMagnitude 244 | self.updateButtonAttribute() 245 | 246 | if let _centerItem = self.scrollView.itemAtIndex(index) { 247 | self.updateCenterItem(_centerItem, animated: false) 248 | } 249 | } 250 | 251 | internal func syncOffset(_ percentComplete: CGFloat) { 252 | if self.percentComplete >= 1.0 { return } 253 | 254 | self.percentComplete = percentComplete 255 | let diff = self.syncContentOffsetXDistance * percentComplete 256 | let offset = self.scrollingTowards ? self.syncStartContentOffsetX - diff : self.syncStartContentOffsetX + diff 257 | 258 | self.scrollView.contentOffset = CGPoint(x: offset, y: 0) 259 | } 260 | 261 | internal func syncSelectedViewWidth(_ percentComplete: CGFloat) { 262 | guard let _currentItem = self.scrollView.itemAtIndex(self.syncStartIndex), 263 | let _nextItem = self.scrollView.itemAtIndex(self.syncNextIndex) else { return } 264 | 265 | let inset = self.selectedViewInsets.left + self.selectedViewInsets.right 266 | let currentWidth = _currentItem.thickness - inset 267 | let nextWidth = _nextItem.thickness - inset 268 | let diff = nextWidth - currentWidth 269 | self.selectedViewWidthConstraint.constant = currentWidth + diff * percentComplete 270 | } 271 | 272 | internal func syncButtons(_ percentComplete: CGFloat) { 273 | guard let _currentItem = self.scrollView.itemAtIndex(self.syncStartIndex), 274 | let _nextItem = self.scrollView.itemAtIndex(self.syncNextIndex) else { return } 275 | 276 | let normal = self.defaultTitleColor.getRGBAStruct() 277 | let selected = self.selectedTitleColor.getRGBAStruct() 278 | 279 | let absRatio = fabs(percentComplete) 280 | 281 | let prevColor = UIColor( 282 | red: normal.red * absRatio + selected.red * (1.0 - absRatio), 283 | green: normal.green * absRatio + selected.green * (1.0 - absRatio), 284 | blue: normal.blue * absRatio + selected.blue * (1.0 - absRatio), 285 | alpha: normal.alpha * absRatio + selected.alpha * (1.0 - absRatio) 286 | ) 287 | let nextColor = UIColor( 288 | red: normal.red * (1.0 - absRatio) + selected.red * absRatio, 289 | green: normal.green * (1.0 - absRatio) + selected.green * absRatio, 290 | blue: normal.blue * (1.0 - absRatio) + selected.blue * absRatio, 291 | alpha: normal.alpha * (1.0 - absRatio) + selected.alpha * absRatio 292 | ) 293 | let currentButton = _currentItem.view as! UIButton 294 | let nextButton = _nextItem.view as! UIButton 295 | 296 | currentButton.setTitleColor(prevColor, for: UIControlState()) 297 | nextButton.setTitleColor(nextColor, for: UIControlState()) 298 | 299 | self.syncButtonTitleColor(currentButton, color: prevColor) 300 | self.syncButtonTitleColor(nextButton, color: nextColor) 301 | } 302 | 303 | internal func syncButtonTitleColor(_ button: UIButton, color: UIColor) { 304 | button.setButtonTitleAttribute(self.defaultTitleFont, textColor: color, state: UIControlState()) 305 | button.setButtonTitleAttribute(self.highlightedTitleFont, textColor: color, state: .highlighted) 306 | button.setButtonTitleAttribute(self.selectedTitleFont, textColor: color, state: .selected) 307 | } 308 | } 309 | 310 | // MARK: - Button Customize 311 | 312 | extension PagerTabMenuView { 313 | 314 | fileprivate func createTitleButton(_ title: String) -> UIButton { 315 | let button = UIButton(frame: CGRect(x: 0.0, y: 0.0, width: self.titleMinWidth, height: self.frame.height)) 316 | button.isExclusiveTouch = true 317 | button.setTitle(title, for: UIControlState()) 318 | self.updateButtonTitleAttribute(button) 319 | button.addTarget(self, action: #selector(PagerTabMenuView.tabMenuButtonTapped(_:)), for: .touchUpInside) 320 | 321 | return button 322 | } 323 | 324 | @objc public func tabMenuButtonTapped(_ sender: UIButton) { 325 | if let _item = self.scrollView.itemAtView(sender) { 326 | self.updateCenterItem(_item, animated: true) 327 | self.selectedIndexHandler?(_item.index) 328 | } 329 | } 330 | 331 | fileprivate func updateButtonAttribute() { 332 | self.scrollView.subviews.forEach() { 333 | let button = $0 as! UIButton 334 | self.updateButtonTitleAttribute(button) 335 | } 336 | } 337 | 338 | fileprivate func updateButtonTitleAttribute(_ button: UIButton) { 339 | button.setButtonTitleAttribute(self.defaultTitleFont, textColor: self.defaultTitleColor, state: UIControlState()) 340 | button.setButtonTitleAttribute(self.highlightedTitleFont, textColor: self.highlightedTitleColor, state: .highlighted) 341 | button.setButtonTitleAttribute(self.selectedTitleFont, textColor: self.selectedTitleColor, state: .selected) 342 | } 343 | } 344 | 345 | extension UIButton { 346 | 347 | public func setButtonTitleAttribute(_ font: UIFont, textColor: UIColor, state: UIControlState) { 348 | guard let _title = self.title(for: UIControlState()) else { return } 349 | 350 | self.setAttributedTitle(NSAttributedString(string: _title, attributes: 351 | [ 352 | NSAttributedStringKey.font: font, 353 | NSAttributedStringKey.foregroundColor: textColor, 354 | ] 355 | ), for: state) 356 | } 357 | } 358 | 359 | // MARK: - Layout 360 | 361 | extension PagerTabMenuView { 362 | 363 | fileprivate func setupConstraint() { 364 | self.allPin(self.backgroundView) 365 | self.allPin(self.scrollView) 366 | 367 | self.selectedViewTopConstraint = self.addPin(self.selectedView, attribute: .top, toView: self, constant: self.selectedViewInsets.top) 368 | self.selectedViewBottomConstraint = self.addPin(self.selectedView, attribute: .bottom, toView: self, constant: -self.selectedViewInsets.bottom) 369 | self.selectedViewWidthConstraint = addConstraint( 370 | self.selectedView, 371 | relation: .equal, 372 | withItem: self.selectedView, 373 | withAttribute: .width, 374 | toItem: nil, 375 | toAttribute: .width, 376 | constant: self.titleMinWidth 377 | ) 378 | _ = addConstraint( 379 | self, 380 | relation: .equal, 381 | withItem: self, 382 | withAttribute: .centerX, 383 | toItem: self.selectedView, 384 | toAttribute: .centerX, 385 | constant: 0 386 | ) 387 | } 388 | 389 | internal func updateSelectedViewLayout(_ animated: Bool) { 390 | self.updateSelectedViewWidth() 391 | self.selectedViewTopConstraint.constant = self.selectedViewInsets.top 392 | self.selectedViewBottomConstraint.constant = -self.selectedViewInsets.bottom 393 | self.updateSelectedViewHandler?(self.selectedView) 394 | 395 | UIView.animate(withDuration: animated ? 0.25 : 0, animations: { 396 | self.selectedView.layoutIfNeeded() 397 | }) 398 | } 399 | 400 | fileprivate func updateSelectedViewWidth() { 401 | guard let _centerItem = self.scrollView.itemAtCenterPosition() else { return } 402 | 403 | let inset = self.selectedViewInsets.left + self.selectedViewInsets.right 404 | self.selectedViewWidthConstraint.constant = _centerItem.thickness - inset 405 | } 406 | 407 | fileprivate func updateCenterItem(_ item: InfiniteItem, animated: Bool) { 408 | self.scrollView.scrollToCenter(item.index, animated: animated, animation: nil, completion: nil) 409 | self.updateSelectedButton(item.index) 410 | self.updateSelectedViewLayout(animated) 411 | } 412 | 413 | fileprivate func updateSelectedButton(_ index: Int) { 414 | self.scrollView.updateItems() { 415 | let itemButton = $0.view as! UIButton 416 | itemButton.isSelected = $0.index == index ? true : false 417 | return $0 418 | } 419 | } 420 | } 421 | 422 | // MARK: - InfiniteScrollViewDataSource 423 | 424 | extension PagerTabMenuView: InfiniteScrollViewDataSource { 425 | 426 | public func totalItemCount() -> Int { 427 | return self.useTitles.count 428 | } 429 | 430 | public func viewForIndex(_ index: Int) -> UIView { 431 | let title = self.useTitles[index] 432 | let button = self.createTitleButton(title) 433 | 434 | return button 435 | } 436 | 437 | public func thicknessForIndex(_ index: Int) -> CGFloat { 438 | let title = self.useTitles[index] 439 | let fontAttr: [NSAttributedStringKey : Any] = [NSAttributedStringKey.font : self.selectedTitleFont] 440 | var width = NSString(string: title).size(withAttributes: fontAttr).width 441 | if width < self.titleMinWidth { 442 | width = self.titleMinWidth 443 | } 444 | return width + self.titleMargin * 2 445 | } 446 | } 447 | 448 | // MARK: - InfiniteScrollViewDelegate 449 | 450 | extension PagerTabMenuView: InfiniteScrollViewDelegate { 451 | 452 | public func updateContentOffset(_ delta: CGFloat) { 453 | self.syncStartContentOffsetX += delta 454 | } 455 | 456 | public func infiniteScrollViewWillBeginDecelerating(_ scrollView: UIScrollView) { 457 | } 458 | 459 | public func infiniteScrollViewWillBeginDragging(_ scrollView: UIScrollView) { 460 | guard !self.isSyncContainerViewScrolling else { return } 461 | 462 | self.willBeginScrollingHandler?(self.selectedView) 463 | } 464 | 465 | public func infinitScrollViewDidScroll(_ scrollView: UIScrollView) { 466 | } 467 | 468 | public func infiniteScrollViewDidEndCenterScrolling(_ item: InfiniteItem) { 469 | guard !self.isSyncContainerViewScrolling else { return } 470 | 471 | self.updateCenterItem(item, animated: false) 472 | self.didEndTabMenuScrollingHandler?(self.selectedView) 473 | self.selectedIndexHandler?(item.index) 474 | } 475 | 476 | public func infiniteScrollViewDidShowCenterItem(_ item: InfiniteItem) { 477 | guard !self.isSyncContainerViewScrolling else { return } 478 | 479 | self.updateCenterItem(item, animated: false) 480 | } 481 | } 482 | -------------------------------------------------------------------------------- /Sources/UIColor+RGBA.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIColor+RGBA.swift 3 | // ViewPagerController 4 | // 5 | // Created by xxxAIRINxxx on 2016/01/05. 6 | // Copyright © 2016 xxxAIRINxxx. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | public struct RGBA { 13 | var red : CGFloat = 0.0 14 | var green : CGFloat = 0.0 15 | var blue : CGFloat = 0.0 16 | var alpha : CGFloat = 0.0 17 | } 18 | 19 | public extension UIColor { 20 | 21 | public func getRGBAStruct() -> RGBA { 22 | let components = self.cgColor.components 23 | let colorSpaceModel = self.cgColor.colorSpace?.model 24 | 25 | if colorSpaceModel?.rawValue == CGColorSpaceModel.rgb.rawValue && self.cgColor.numberOfComponents == 4 { 26 | return RGBA( 27 | red: components![0], 28 | green: components![1], 29 | blue: components![2], 30 | alpha: components![3] 31 | ) 32 | } else if colorSpaceModel?.rawValue == CGColorSpaceModel.monochrome.rawValue && self.cgColor.numberOfComponents == 2 { 33 | return RGBA( 34 | red: components![0], 35 | green: components![0], 36 | blue: components![0], 37 | alpha: components![1] 38 | ) 39 | } else { 40 | return RGBA() 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Sources/UIView+AutoLayout.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+AutoLayout.swift 3 | // ViewPagerController 4 | // 5 | // Created by xxxAIRINxxx on 2016/01/05. 6 | // Copyright © 2016 xxxAIRINxxx. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | public extension UIView { 13 | 14 | public func checkTranslatesAutoresizing(_ withView: UIView?, toView: UIView?) { 15 | if self.translatesAutoresizingMaskIntoConstraints == true { 16 | self.translatesAutoresizingMaskIntoConstraints = false 17 | } 18 | 19 | if let _withView = withView { 20 | if _withView.translatesAutoresizingMaskIntoConstraints == true { 21 | _withView.translatesAutoresizingMaskIntoConstraints = false 22 | } 23 | } 24 | 25 | if let _toView = toView { 26 | if _toView.translatesAutoresizingMaskIntoConstraints == true { 27 | _toView.translatesAutoresizingMaskIntoConstraints = false 28 | } 29 | } 30 | } 31 | 32 | public func addPin(_ withView:UIView, attribute:NSLayoutAttribute, toView:UIView?, constant:CGFloat) -> NSLayoutConstraint { 33 | checkTranslatesAutoresizing(withView, toView: toView) 34 | return addPinConstraint(self, withItem: withView, toItem: toView, attribute: attribute, constant: constant) 35 | } 36 | 37 | public func addPin(_ withView:UIView, isWithViewTop:Bool, toView:UIView?, isToViewTop:Bool, constant:CGFloat) -> NSLayoutConstraint { 38 | checkTranslatesAutoresizing(withView, toView: toView) 39 | return addConstraint( 40 | self, 41 | relation: .equal, 42 | withItem: withView, 43 | withAttribute: (isWithViewTop == true ? .top : .bottom), 44 | toItem: toView, 45 | toAttribute: (isToViewTop == true ? .top : .bottom), 46 | constant: constant 47 | ) 48 | } 49 | 50 | public func allPin(_ subView: UIView) { 51 | checkTranslatesAutoresizing(subView, toView: nil) 52 | _ = addPinConstraint(self, withItem: subView, toItem: self, attribute: .top, constant: 0.0) 53 | _ = addPinConstraint(self, withItem: subView, toItem: self, attribute: .bottom, constant: 0.0) 54 | _ = addPinConstraint(self, withItem: subView, toItem: self, attribute: .left, constant: 0.0) 55 | _ = addPinConstraint(self, withItem: subView, toItem: self, attribute: .right, constant: 0.0) 56 | } 57 | 58 | // MARK: NSLayoutConstraint 59 | 60 | public func addPinConstraint(_ parentView: UIView, withItem:UIView, toItem:UIView?, attribute:NSLayoutAttribute, constant:CGFloat) -> NSLayoutConstraint { 61 | return addConstraint( 62 | parentView, 63 | relation: .equal, 64 | withItem: withItem, 65 | withAttribute: attribute, 66 | toItem: toItem, 67 | toAttribute: attribute, 68 | constant: constant 69 | ) 70 | } 71 | 72 | public func addWidthConstraint(_ view: UIView, constant:CGFloat) -> NSLayoutConstraint { 73 | return addConstraint( 74 | view, 75 | relation: .equal, 76 | withItem: view, 77 | withAttribute: .width, 78 | toItem: nil, 79 | toAttribute: .width, 80 | constant: constant 81 | ) 82 | } 83 | 84 | public func addHeightConstraint(_ view: UIView, constant:CGFloat) -> NSLayoutConstraint { 85 | return addConstraint( 86 | view, 87 | relation: .equal, 88 | withItem: view, 89 | withAttribute: .height, 90 | toItem: nil, 91 | toAttribute: .height, 92 | constant: constant 93 | ) 94 | } 95 | 96 | public func addConstraint(_ addView: UIView, relation: NSLayoutRelation, withItem:UIView, withAttribute:NSLayoutAttribute, toItem:UIView?, toAttribute:NSLayoutAttribute, constant:CGFloat) -> NSLayoutConstraint { 97 | let constraint = NSLayoutConstraint( 98 | item: withItem, 99 | attribute: withAttribute, 100 | relatedBy: relation, 101 | toItem: toItem, 102 | attribute: toAttribute, 103 | multiplier: 1.0, 104 | constant: constant 105 | ) 106 | 107 | addView.addConstraint(constraint) 108 | 109 | return constraint 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /Sources/ViewPagerController+ScrollHeaderSupport.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewPagerController+ScrollHeaderSupport.swift 3 | // ViewPagerController 4 | // 5 | // Created by xxxAIRINxxx on 2016/01/05. 6 | // Copyright © 2016 xxxAIRINxxx. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | extension ViewPagerController { 13 | 14 | // MARK: - Override (KVO) 15 | 16 | override public func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) { 17 | if (keyPath == "contentOffset") { 18 | 19 | let old = (change?[NSKeyValueChangeKey.oldKey] as AnyObject).cgPointValue 20 | let new = (change?[NSKeyValueChangeKey.newKey] as AnyObject).cgPointValue 21 | 22 | guard let _old = old, let _new = new else { return } 23 | 24 | switch self.scrollViewObservingType { 25 | case .header: 26 | self.updateHeaderViewHeight(_old, currentOffset: _new) 27 | case .navigationBar: 28 | self.updateNavigationBarHeight(_old, currentOffset: _new) 29 | case .none: 30 | break 31 | } 32 | } 33 | } 34 | 35 | // MARK: - Public Functions 36 | 37 | public func resetHeaderViewHeight(_ animated: Bool) { 38 | self.headerViewHeightConstraint.constant = self.headerViewHeight 39 | UIView.animate(withDuration: animated ? 0.25 : 0, animations: { 40 | self.view.layoutIfNeeded() 41 | }) 42 | } 43 | 44 | public func resetNavigationBarHeight(_ animated: Bool) { 45 | if let _navigationBar = self.targetNavigationBar { 46 | self.viewTopConstraint.constant = 0 47 | UIView.animate(withDuration: animated ? 0.25 : 0, animations: { 48 | _navigationBar.frame.origin.y = self.navigationBarBaselineOriginY() 49 | self.view.layoutIfNeeded() 50 | }) 51 | } 52 | } 53 | 54 | // MARK: - Private Functions 55 | 56 | fileprivate func updateHeaderViewHeight(_ prevOffset: CGPoint, currentOffset: CGPoint) { 57 | let maxHeaderHeight = self.headerViewHeight 58 | let minHeaderHeight = self.scrollViewMinPositionY 59 | 60 | if prevOffset.y == currentOffset.y { return } 61 | 62 | if prevOffset.y <= currentOffset.y { 63 | // down scrolling 64 | if currentOffset.y <= 0 { return } 65 | 66 | let diff = currentOffset.y - prevOffset.y 67 | if (self.headerViewHeightConstraint.constant - diff) < minHeaderHeight { 68 | if self.headerViewHeightConstraint.constant == minHeaderHeight { return } 69 | self.headerViewHeightConstraint.constant = minHeaderHeight 70 | } else { 71 | self.headerViewHeightConstraint.constant -= diff * self.scrollViewObservingDelay 72 | } 73 | } else { 74 | // up scrolling 75 | if currentOffset.y > self.headerViewHeight { return } 76 | 77 | let diff = prevOffset.y - currentOffset.y 78 | if (self.headerViewHeightConstraint.constant + diff) > maxHeaderHeight { 79 | if self.headerViewHeightConstraint.constant == maxHeaderHeight { return } 80 | self.headerViewHeightConstraint.constant = maxHeaderHeight 81 | } else { 82 | self.headerViewHeightConstraint.constant += diff * self.scrollViewObservingDelay 83 | } 84 | } 85 | self.view.layoutIfNeeded() 86 | self.didChangeHeaderViewHeightHandler?(self.headerViewHeightConstraint.constant) 87 | } 88 | 89 | fileprivate func updateNavigationBarHeight(_ prevOffset: CGPoint, currentOffset: CGPoint) { 90 | if let _navigationBar = self.targetNavigationBar { 91 | let minHeaderHeight = self.scrollViewMinPositionY 92 | let baselineOriginY = self.navigationBarBaselineOriginY() 93 | let visibleBarHeight = _navigationBar.frame.size.height + _navigationBar.frame.origin.y 94 | let minNavigatonBarOriginY = -(_navigationBar.frame.size.height - minHeaderHeight) 95 | 96 | if prevOffset.y == currentOffset.y { return } 97 | 98 | if prevOffset.y <= currentOffset.y { 99 | // down scrolling 100 | if currentOffset.y <= 0 { return } 101 | let diff = currentOffset.y - prevOffset.y 102 | 103 | if (visibleBarHeight - diff) < minHeaderHeight { 104 | _navigationBar.frame.origin.y = minNavigatonBarOriginY 105 | self.viewTopConstraint.constant = minNavigatonBarOriginY - baselineOriginY 106 | } else { 107 | _navigationBar.frame.origin.y -= diff * self.scrollViewObservingDelay 108 | self.viewTopConstraint.constant -= diff * self.scrollViewObservingDelay 109 | } 110 | } else { 111 | // up scrolling 112 | if currentOffset.y > (baselineOriginY + _navigationBar.frame.size.height) { return } 113 | 114 | let diff = prevOffset.y - currentOffset.y 115 | if (_navigationBar.frame.origin.y + diff) > baselineOriginY { 116 | _navigationBar.frame.origin.y = baselineOriginY 117 | self.viewTopConstraint.constant = 0 118 | } else { 119 | _navigationBar.frame.origin.y += diff * self.scrollViewObservingDelay 120 | self.viewTopConstraint.constant += diff * self.scrollViewObservingDelay 121 | } 122 | } 123 | self.view.layoutIfNeeded() 124 | self.didChangeHeaderViewHeightHandler?(visibleBarHeight) 125 | } 126 | } 127 | 128 | fileprivate func navigationBarBaselineOriginY() -> CGFloat { 129 | return UIApplication.shared.statusBarFrame.size.height 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /Sources/ViewPagerController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewPagerController.h 3 | // ViewPagerController 4 | // 5 | // Created by xxxAIRINxxx on 2016/02/16. 6 | // Copyright © 2016 xxxAIRINxxx. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for ViewPagerController. 12 | FOUNDATION_EXPORT double ViewPagerControllerVersionNumber; 13 | 14 | //! Project version string for ViewPagerController. 15 | FOUNDATION_EXPORT const unsigned char ViewPagerControllerVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /Sources/ViewPagerController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewPagerController.swift 3 | // ViewPagerController 4 | // 5 | // Created by xxxAIRINxxx on 2016/01/05. 6 | // Copyright © 2016 xxxAIRINxxx. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | public enum ObservingScrollViewType { 13 | case none 14 | case header 15 | case navigationBar(targetNavigationBar : UINavigationBar) 16 | } 17 | 18 | public final class ViewPagerController: UIViewController { 19 | 20 | // MARK: - Public Handler Properties 21 | 22 | public var didShowViewControllerHandler : ((UIViewController) -> Void)? 23 | 24 | public var updateSelectedViewHandler : ((UIView) -> Void)? 25 | 26 | public var willBeginTabMenuUserScrollingHandler : ((UIView) -> Void)? 27 | 28 | public var didEndTabMenuUserScrollingHandler : ((UIView) -> Void)? 29 | 30 | public var didChangeHeaderViewHeightHandler : ((CGFloat) -> Void)? 31 | 32 | public var changeObserveScrollViewHandler : ((UIViewController) -> UIScrollView?)? 33 | 34 | public var didScrollContentHandler : ((CGFloat) -> Void)? 35 | 36 | // MARK: - Custom Settings Properties 37 | 38 | public fileprivate(set) var headerViewHeight : CGFloat = 0.0 39 | public fileprivate(set) var tabMenuViewHeight : CGFloat = 0.0 40 | 41 | // ScrollHeaderSupport 42 | public fileprivate(set) var scrollViewMinPositionY : CGFloat = 0.0 43 | public fileprivate(set) var scrollViewObservingDelay : CGFloat = 0.0 44 | public fileprivate(set) var scrollViewObservingType : ObservingScrollViewType = .none { 45 | didSet { 46 | switch self.scrollViewObservingType { 47 | case .header: 48 | self.targetNavigationBar = nil 49 | case .navigationBar(let targetNavigationBar): 50 | self.targetNavigationBar = targetNavigationBar 51 | case .none: 52 | self.targetNavigationBar = nil 53 | self.observingScrollView = nil 54 | } 55 | } 56 | } 57 | 58 | // MARK: - Private Properties 59 | 60 | internal var headerView : UIView = UIView(frame: CGRect.zero) 61 | 62 | internal var tabMenuView : PagerTabMenuView = PagerTabMenuView(frame: CGRect.zero) 63 | 64 | internal var containerView : PagerContainerView = PagerContainerView(frame: CGRect.zero) 65 | 66 | internal var targetNavigationBar : UINavigationBar? 67 | 68 | internal var headerViewHeightConstraint : NSLayoutConstraint! 69 | 70 | internal var tabMenuViewHeightConstraint : NSLayoutConstraint! 71 | 72 | internal var viewTopConstraint : NSLayoutConstraint! 73 | 74 | internal var observingScrollView : UIScrollView? { 75 | willSet { self.stopScrollViewContentOffsetObserving() } 76 | didSet { self.startScrollViewContentOffsetObserving() } 77 | } 78 | 79 | // MARK: - Override 80 | 81 | deinit { 82 | self.scrollViewObservingType = .none 83 | } 84 | 85 | public override func viewDidLoad() { 86 | super.viewDidLoad() 87 | 88 | self.view.addSubview(self.containerView) 89 | self.view.addSubview(self.tabMenuView) 90 | self.view.addSubview(self.headerView) 91 | 92 | self.setupConstraint() 93 | self.setupHandler() 94 | self.updateAppearance(ViewPagerControllerAppearance()) 95 | } 96 | 97 | public override func viewDidDisappear(_ animated: Bool) { 98 | super.viewDidDisappear(animated) 99 | 100 | self.tabMenuView.stopScrolling(self.containerView.currentIndex() ?? 0) 101 | self.didEndTabMenuUserScrollingHandler?(self.tabMenuView.getSelectedView()) 102 | self.tabMenuView.updateSelectedViewLayout(false) 103 | } 104 | 105 | // MARK: - Public Functions 106 | 107 | public func updateAppearance(_ appearance: ViewPagerControllerAppearance) { 108 | // Header 109 | self.headerViewHeight = appearance.headerHeight 110 | self.headerViewHeightConstraint.constant = self.headerViewHeight 111 | 112 | self.headerView.subviews.forEach() { $0.removeFromSuperview() } 113 | if let _contentsView = appearance.headerContentsView { 114 | self.headerView.addSubview(_contentsView) 115 | self.headerView.allPin(_contentsView) 116 | } 117 | 118 | // Tab Menu 119 | self.tabMenuViewHeight = appearance.tabMenuHeight 120 | self.tabMenuViewHeightConstraint.constant = self.tabMenuViewHeight 121 | self.tabMenuView.updateAppearance(appearance.tabMenuAppearance) 122 | 123 | // ScrollHeaderSupport 124 | self.scrollViewMinPositionY = appearance.scrollViewMinPositionY 125 | self.scrollViewObservingType = appearance.scrollViewObservingType 126 | self.scrollViewObservingDelay = appearance.scrollViewObservingDelay 127 | 128 | self.view.layoutIfNeeded() 129 | } 130 | 131 | public func setParentController(_ controller: UIViewController, parentView: UIView) { 132 | controller.automaticallyAdjustsScrollViewInsets = false 133 | controller.addChildViewController(self) 134 | 135 | parentView.addSubview(self.view) 136 | 137 | self.viewTopConstraint = parentView.addPin(self.view, attribute: .top, toView: parentView, constant: 0.0) 138 | _ = parentView.addPin(self.view, attribute: .bottom, toView: parentView, constant: 0.0) 139 | _ = parentView.addPin(self.view, attribute: .left, toView: parentView, constant: 0.0) 140 | _ = parentView.addPin(self.view, attribute: .right, toView: parentView, constant: 0.0) 141 | 142 | self.didMove(toParentViewController: controller) 143 | } 144 | 145 | public func addContent(_ title: String, viewController: UIViewController) { 146 | self.tabMenuView.addTitle(title) 147 | self.addChildViewController(viewController) 148 | self.containerView.addViewController(viewController) 149 | } 150 | 151 | public func removeContent(_ viewController: UIViewController) { 152 | guard let index = self.containerView.indexFromViewController(viewController) else { return } 153 | 154 | if self.childViewControllers.contains(viewController) { 155 | viewController.willMove(toParentViewController: nil) 156 | 157 | self.tabMenuView.removeContentAtIndex(index) 158 | self.containerView.removeContent(viewController) 159 | 160 | viewController.removeFromParentViewController() 161 | } 162 | } 163 | 164 | public func currentContent() -> UIViewController? { 165 | return self.containerView.currentContent() 166 | } 167 | 168 | // MARK: - Private Functions 169 | 170 | fileprivate func setupConstraint() { 171 | // Header 172 | _ = self.view.addPin(self.headerView, attribute: .top, toView: self.view, constant: 0.0) 173 | self.headerViewHeightConstraint = self.headerView.addHeightConstraint(self.headerView, constant: self.headerViewHeight) 174 | _ = self.view.addPin(self.headerView, attribute: .left, toView: self.view, constant: 0.0) 175 | _ = self.view.addPin(self.headerView, attribute: .right, toView: self.view, constant: 0.0) 176 | 177 | // Tab Menu 178 | _ = self.view.addPin(self.tabMenuView, isWithViewTop: true, toView: self.headerView, isToViewTop: false, constant: 0.0) 179 | self.tabMenuViewHeightConstraint = self.tabMenuView.addHeightConstraint(self.tabMenuView, constant: self.tabMenuViewHeight) 180 | _ = self.view.addPin(self.tabMenuView, attribute: .left, toView: self.view, constant: 0.0) 181 | _ = self.view.addPin(self.tabMenuView, attribute: .right, toView: self.view, constant: 0.0) 182 | 183 | // Container 184 | _ = self.view.addPin(self.containerView, isWithViewTop: true, toView: self.tabMenuView, isToViewTop: false, constant: 0.0) 185 | _ = self.view.addPin(self.containerView, attribute: .bottom, toView: self.view, constant: 0.0) 186 | _ = self.view.addPin(self.containerView, attribute: .left, toView: self.view, constant: 0.0) 187 | _ = self.view.addPin(self.containerView, attribute: .right, toView: self.view, constant: 0.0) 188 | } 189 | 190 | fileprivate func setupHandler() { 191 | self.tabMenuView.selectedIndexHandler = { [weak self] index in 192 | self?.containerView.scrollToCenter(index, animated: true, animation: nil, completion: nil) 193 | } 194 | 195 | self.tabMenuView.updateSelectedViewHandler = { [weak self] selectedView in 196 | self?.updateSelectedViewHandler?(selectedView) 197 | } 198 | 199 | self.tabMenuView.willBeginScrollingHandler = { [weak self] selectedView in 200 | self?.willBeginTabMenuUserScrollingHandler?(selectedView) 201 | } 202 | 203 | self.tabMenuView.didEndTabMenuScrollingHandler = { [weak self] selectedView in 204 | self?.didEndTabMenuUserScrollingHandler?(selectedView) 205 | } 206 | 207 | self.containerView.startSyncHandler = { [weak self] index in 208 | self?.tabMenuView.stopScrolling(index) 209 | } 210 | 211 | self.containerView.syncOffsetHandler = { [weak self] index, percentComplete, scrollingTowards in 212 | self?.tabMenuView.syncContainerViewScrollTo(index, percentComplete: percentComplete, scrollingTowards: scrollingTowards) 213 | self?.didScrollContentHandler?(percentComplete) 214 | } 215 | 216 | self.containerView.finishSyncHandler = { [weak self] index in 217 | self?.tabMenuView.finishSyncContainerViewScroll(index) 218 | } 219 | 220 | self.containerView.didShowViewControllerHandler = { [weak self] controller in 221 | self?.didShowViewControllerHandler?(controller) 222 | let scrollView = self?.changeObserveScrollViewHandler?(controller) 223 | self?.observingScrollView = scrollView 224 | } 225 | } 226 | 227 | fileprivate func startScrollViewContentOffsetObserving() { 228 | if let _observingScrollView = self.observingScrollView { 229 | _observingScrollView.addObserver(self, forKeyPath: "contentOffset", options: [.old, .new], context: nil) 230 | } 231 | } 232 | 233 | fileprivate func stopScrollViewContentOffsetObserving() { 234 | if let _observingScrollView = self.observingScrollView { 235 | _observingScrollView.removeObserver(self, forKeyPath: "contentOffset") 236 | } 237 | } 238 | } 239 | -------------------------------------------------------------------------------- /Sources/ViewPagerControllerAppearance.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewPagerControllerAppearance.swift 3 | // ViewPagerController 4 | // 5 | // Created by xxxAIRINxxx on 2016/01/06. 6 | // Copyright © 2016 xxxAIRINxxx. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | public struct ViewPagerControllerAppearance { 13 | 14 | public init() {} 15 | 16 | // Header 17 | public var headerHeight : CGFloat = 0.0 18 | public var tabMenuHeight : CGFloat = 44.0 19 | public var headerContentsView : UIView? 20 | 21 | // TabMenu 22 | public var tabMenuAppearance : TabMenuAppearance = TabMenuAppearance() 23 | 24 | // ScrollHeaderSupport 25 | public var scrollViewMinPositionY : CGFloat = 20.0 26 | public var scrollViewObservingType : ObservingScrollViewType = .none 27 | public var scrollViewObservingDelay : CGFloat = 0.5 28 | } 29 | 30 | public struct TabMenuAppearance { 31 | 32 | public init() {} 33 | 34 | public var backgroundColor : UIColor = UIColor.black 35 | 36 | // Title Layout 37 | public var titleMargin : CGFloat = 15.0 38 | public var titleMinWidth : CGFloat = 30.0 39 | 40 | // Title Color 41 | public var defaultTitleColor : UIColor = UIColor.gray 42 | public var highlightedTitleColor : UIColor = UIColor.white 43 | public var selectedTitleColor : UIColor = UIColor.white 44 | 45 | // Title Font 46 | public var defaultTitleFont : UIFont = UIFont.systemFont(ofSize: 14) 47 | public var highlightedTitleFont : UIFont = UIFont.systemFont(ofSize: 14) 48 | public var selectedTitleFont : UIFont = UIFont.boldSystemFont(ofSize: 15) 49 | 50 | // Selected View 51 | public var selectedViewBackgroundColor : UIColor = UIColor.green 52 | public var selectedViewInsets : UIEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) 53 | 54 | public var backgroundContentsView : UIView? 55 | } 56 | -------------------------------------------------------------------------------- /ViewPagerController.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "ViewPagerController" 3 | s.version = "2.0.0" 4 | s.summary = "Infinite menu & view paging Controller. written in Swift." 5 | s.homepage = "https://github.com/xxxAIRINxxx/ViewPagerController" 6 | s.license = 'MIT' 7 | s.author = { "Airin" => "xl1138@gmail.com" } 8 | s.source = { :git => "https://github.com/xxxAIRINxxx/ViewPagerController.git", :tag => s.version.to_s } 9 | 10 | s.requires_arc = true 11 | s.platform = :ios, '9.0' 12 | 13 | s.source_files = 'Sources/*.swift' 14 | end 15 | -------------------------------------------------------------------------------- /capture1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xxxAIRINxxx/ViewPagerController/7c28a509daf8a53007a6ed610086e07891379fbb/capture1.gif -------------------------------------------------------------------------------- /capture2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xxxAIRINxxx/ViewPagerController/7c28a509daf8a53007a6ed610086e07891379fbb/capture2.gif --------------------------------------------------------------------------------