├── .gitignore ├── README.md ├── SwipeBetweenViewControllers.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── SwipeBetweenViewControllers ├── AppDelegate.swift ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard ├── Default-568h@2x.png ├── Images.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Info.plist └── SwipeBetweenViewControllers.swift └── SwipeBetweenViewControllersTests ├── Info.plist └── SwipeBetweenViewControllersTests.swift /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | # Pods/ 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | SwipeBetweenViewControllers 2 | =========================== 3 | 4 | SwipeBetweenViewControllers is based on RKSwipeBetweenViewControllers used Swift. 5 | 6 | ##demo 7 | ![demo](http://hayatomo.com/wordpress/wp-content/uploads/SwipeBetweenViewControllers.gif) 8 | ![demo](http://i.imgur.com/zlfWDa1.gif) 9 | 10 | ##License 11 | MIT License. -------------------------------------------------------------------------------- /SwipeBetweenViewControllers.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | B1C875861A0DE4C800ABE09F /* SwipeBetweenViewControllers.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1C875851A0DE4C800ABE09F /* SwipeBetweenViewControllers.swift */; }; 11 | B1C875891A0DED1100ABE09F /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = B1C875881A0DED1100ABE09F /* Default-568h@2x.png */; }; 12 | B1D9DDBE19FF6B08001615F7 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1D9DDBD19FF6B08001615F7 /* AppDelegate.swift */; }; 13 | B1D9DDC319FF6B08001615F7 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B1D9DDC119FF6B08001615F7 /* Main.storyboard */; }; 14 | B1D9DDC519FF6B08001615F7 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B1D9DDC419FF6B08001615F7 /* Images.xcassets */; }; 15 | B1D9DDC819FF6B08001615F7 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = B1D9DDC619FF6B08001615F7 /* LaunchScreen.xib */; }; 16 | B1D9DDD419FF6B08001615F7 /* SwipeBetweenViewControllersTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1D9DDD319FF6B08001615F7 /* SwipeBetweenViewControllersTests.swift */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXContainerItemProxy section */ 20 | B1D9DDCE19FF6B08001615F7 /* PBXContainerItemProxy */ = { 21 | isa = PBXContainerItemProxy; 22 | containerPortal = B1D9DDB019FF6B08001615F7 /* Project object */; 23 | proxyType = 1; 24 | remoteGlobalIDString = B1D9DDB719FF6B08001615F7; 25 | remoteInfo = SwipeBetweenViewControllers; 26 | }; 27 | /* End PBXContainerItemProxy section */ 28 | 29 | /* Begin PBXFileReference section */ 30 | B1C875851A0DE4C800ABE09F /* SwipeBetweenViewControllers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwipeBetweenViewControllers.swift; sourceTree = ""; }; 31 | B1C875881A0DED1100ABE09F /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 32 | B1D9DDB819FF6B08001615F7 /* SwipeBetweenViewControllers.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwipeBetweenViewControllers.app; sourceTree = BUILT_PRODUCTS_DIR; }; 33 | B1D9DDBC19FF6B08001615F7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 34 | B1D9DDBD19FF6B08001615F7 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 35 | B1D9DDC219FF6B08001615F7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 36 | B1D9DDC419FF6B08001615F7 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 37 | B1D9DDC719FF6B08001615F7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 38 | B1D9DDCD19FF6B08001615F7 /* SwipeBetweenViewControllersTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwipeBetweenViewControllersTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 39 | B1D9DDD219FF6B08001615F7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 40 | B1D9DDD319FF6B08001615F7 /* SwipeBetweenViewControllersTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwipeBetweenViewControllersTests.swift; sourceTree = ""; }; 41 | /* End PBXFileReference section */ 42 | 43 | /* Begin PBXFrameworksBuildPhase section */ 44 | B1D9DDB519FF6B08001615F7 /* Frameworks */ = { 45 | isa = PBXFrameworksBuildPhase; 46 | buildActionMask = 2147483647; 47 | files = ( 48 | ); 49 | runOnlyForDeploymentPostprocessing = 0; 50 | }; 51 | B1D9DDCA19FF6B08001615F7 /* Frameworks */ = { 52 | isa = PBXFrameworksBuildPhase; 53 | buildActionMask = 2147483647; 54 | files = ( 55 | ); 56 | runOnlyForDeploymentPostprocessing = 0; 57 | }; 58 | /* End PBXFrameworksBuildPhase section */ 59 | 60 | /* Begin PBXGroup section */ 61 | B1D9DDAF19FF6B08001615F7 = { 62 | isa = PBXGroup; 63 | children = ( 64 | B1D9DDBA19FF6B08001615F7 /* SwipeBetweenViewControllers */, 65 | B1D9DDD019FF6B08001615F7 /* SwipeBetweenViewControllersTests */, 66 | B1D9DDB919FF6B08001615F7 /* Products */, 67 | ); 68 | sourceTree = ""; 69 | }; 70 | B1D9DDB919FF6B08001615F7 /* Products */ = { 71 | isa = PBXGroup; 72 | children = ( 73 | B1D9DDB819FF6B08001615F7 /* SwipeBetweenViewControllers.app */, 74 | B1D9DDCD19FF6B08001615F7 /* SwipeBetweenViewControllersTests.xctest */, 75 | ); 76 | name = Products; 77 | sourceTree = ""; 78 | }; 79 | B1D9DDBA19FF6B08001615F7 /* SwipeBetweenViewControllers */ = { 80 | isa = PBXGroup; 81 | children = ( 82 | B1D9DDBD19FF6B08001615F7 /* AppDelegate.swift */, 83 | B1C875851A0DE4C800ABE09F /* SwipeBetweenViewControllers.swift */, 84 | B1D9DDC119FF6B08001615F7 /* Main.storyboard */, 85 | B1D9DDC419FF6B08001615F7 /* Images.xcassets */, 86 | B1D9DDC619FF6B08001615F7 /* LaunchScreen.xib */, 87 | B1D9DDBB19FF6B08001615F7 /* Supporting Files */, 88 | ); 89 | path = SwipeBetweenViewControllers; 90 | sourceTree = ""; 91 | }; 92 | B1D9DDBB19FF6B08001615F7 /* Supporting Files */ = { 93 | isa = PBXGroup; 94 | children = ( 95 | B1C875881A0DED1100ABE09F /* Default-568h@2x.png */, 96 | B1D9DDBC19FF6B08001615F7 /* Info.plist */, 97 | ); 98 | name = "Supporting Files"; 99 | sourceTree = ""; 100 | }; 101 | B1D9DDD019FF6B08001615F7 /* SwipeBetweenViewControllersTests */ = { 102 | isa = PBXGroup; 103 | children = ( 104 | B1D9DDD319FF6B08001615F7 /* SwipeBetweenViewControllersTests.swift */, 105 | B1D9DDD119FF6B08001615F7 /* Supporting Files */, 106 | ); 107 | path = SwipeBetweenViewControllersTests; 108 | sourceTree = ""; 109 | }; 110 | B1D9DDD119FF6B08001615F7 /* Supporting Files */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | B1D9DDD219FF6B08001615F7 /* Info.plist */, 114 | ); 115 | name = "Supporting Files"; 116 | sourceTree = ""; 117 | }; 118 | /* End PBXGroup section */ 119 | 120 | /* Begin PBXNativeTarget section */ 121 | B1D9DDB719FF6B08001615F7 /* SwipeBetweenViewControllers */ = { 122 | isa = PBXNativeTarget; 123 | buildConfigurationList = B1D9DDD719FF6B08001615F7 /* Build configuration list for PBXNativeTarget "SwipeBetweenViewControllers" */; 124 | buildPhases = ( 125 | B1D9DDB419FF6B08001615F7 /* Sources */, 126 | B1D9DDB519FF6B08001615F7 /* Frameworks */, 127 | B1D9DDB619FF6B08001615F7 /* Resources */, 128 | ); 129 | buildRules = ( 130 | ); 131 | dependencies = ( 132 | ); 133 | name = SwipeBetweenViewControllers; 134 | productName = SwipeBetweenViewControllers; 135 | productReference = B1D9DDB819FF6B08001615F7 /* SwipeBetweenViewControllers.app */; 136 | productType = "com.apple.product-type.application"; 137 | }; 138 | B1D9DDCC19FF6B08001615F7 /* SwipeBetweenViewControllersTests */ = { 139 | isa = PBXNativeTarget; 140 | buildConfigurationList = B1D9DDDA19FF6B08001615F7 /* Build configuration list for PBXNativeTarget "SwipeBetweenViewControllersTests" */; 141 | buildPhases = ( 142 | B1D9DDC919FF6B08001615F7 /* Sources */, 143 | B1D9DDCA19FF6B08001615F7 /* Frameworks */, 144 | B1D9DDCB19FF6B08001615F7 /* Resources */, 145 | ); 146 | buildRules = ( 147 | ); 148 | dependencies = ( 149 | B1D9DDCF19FF6B08001615F7 /* PBXTargetDependency */, 150 | ); 151 | name = SwipeBetweenViewControllersTests; 152 | productName = SwipeBetweenViewControllersTests; 153 | productReference = B1D9DDCD19FF6B08001615F7 /* SwipeBetweenViewControllersTests.xctest */; 154 | productType = "com.apple.product-type.bundle.unit-test"; 155 | }; 156 | /* End PBXNativeTarget section */ 157 | 158 | /* Begin PBXProject section */ 159 | B1D9DDB019FF6B08001615F7 /* Project object */ = { 160 | isa = PBXProject; 161 | attributes = { 162 | LastUpgradeCheck = 0610; 163 | ORGANIZATIONNAME = "HAYAKAWA TOMOAKI"; 164 | TargetAttributes = { 165 | B1D9DDB719FF6B08001615F7 = { 166 | CreatedOnToolsVersion = 6.1; 167 | }; 168 | B1D9DDCC19FF6B08001615F7 = { 169 | CreatedOnToolsVersion = 6.1; 170 | TestTargetID = B1D9DDB719FF6B08001615F7; 171 | }; 172 | }; 173 | }; 174 | buildConfigurationList = B1D9DDB319FF6B08001615F7 /* Build configuration list for PBXProject "SwipeBetweenViewControllers" */; 175 | compatibilityVersion = "Xcode 3.2"; 176 | developmentRegion = English; 177 | hasScannedForEncodings = 0; 178 | knownRegions = ( 179 | en, 180 | Base, 181 | ); 182 | mainGroup = B1D9DDAF19FF6B08001615F7; 183 | productRefGroup = B1D9DDB919FF6B08001615F7 /* Products */; 184 | projectDirPath = ""; 185 | projectRoot = ""; 186 | targets = ( 187 | B1D9DDB719FF6B08001615F7 /* SwipeBetweenViewControllers */, 188 | B1D9DDCC19FF6B08001615F7 /* SwipeBetweenViewControllersTests */, 189 | ); 190 | }; 191 | /* End PBXProject section */ 192 | 193 | /* Begin PBXResourcesBuildPhase section */ 194 | B1D9DDB619FF6B08001615F7 /* Resources */ = { 195 | isa = PBXResourcesBuildPhase; 196 | buildActionMask = 2147483647; 197 | files = ( 198 | B1D9DDC319FF6B08001615F7 /* Main.storyboard in Resources */, 199 | B1C875891A0DED1100ABE09F /* Default-568h@2x.png in Resources */, 200 | B1D9DDC819FF6B08001615F7 /* LaunchScreen.xib in Resources */, 201 | B1D9DDC519FF6B08001615F7 /* Images.xcassets in Resources */, 202 | ); 203 | runOnlyForDeploymentPostprocessing = 0; 204 | }; 205 | B1D9DDCB19FF6B08001615F7 /* Resources */ = { 206 | isa = PBXResourcesBuildPhase; 207 | buildActionMask = 2147483647; 208 | files = ( 209 | ); 210 | runOnlyForDeploymentPostprocessing = 0; 211 | }; 212 | /* End PBXResourcesBuildPhase section */ 213 | 214 | /* Begin PBXSourcesBuildPhase section */ 215 | B1D9DDB419FF6B08001615F7 /* Sources */ = { 216 | isa = PBXSourcesBuildPhase; 217 | buildActionMask = 2147483647; 218 | files = ( 219 | B1C875861A0DE4C800ABE09F /* SwipeBetweenViewControllers.swift in Sources */, 220 | B1D9DDBE19FF6B08001615F7 /* AppDelegate.swift in Sources */, 221 | ); 222 | runOnlyForDeploymentPostprocessing = 0; 223 | }; 224 | B1D9DDC919FF6B08001615F7 /* Sources */ = { 225 | isa = PBXSourcesBuildPhase; 226 | buildActionMask = 2147483647; 227 | files = ( 228 | B1D9DDD419FF6B08001615F7 /* SwipeBetweenViewControllersTests.swift in Sources */, 229 | ); 230 | runOnlyForDeploymentPostprocessing = 0; 231 | }; 232 | /* End PBXSourcesBuildPhase section */ 233 | 234 | /* Begin PBXTargetDependency section */ 235 | B1D9DDCF19FF6B08001615F7 /* PBXTargetDependency */ = { 236 | isa = PBXTargetDependency; 237 | target = B1D9DDB719FF6B08001615F7 /* SwipeBetweenViewControllers */; 238 | targetProxy = B1D9DDCE19FF6B08001615F7 /* PBXContainerItemProxy */; 239 | }; 240 | /* End PBXTargetDependency section */ 241 | 242 | /* Begin PBXVariantGroup section */ 243 | B1D9DDC119FF6B08001615F7 /* Main.storyboard */ = { 244 | isa = PBXVariantGroup; 245 | children = ( 246 | B1D9DDC219FF6B08001615F7 /* Base */, 247 | ); 248 | name = Main.storyboard; 249 | sourceTree = ""; 250 | }; 251 | B1D9DDC619FF6B08001615F7 /* LaunchScreen.xib */ = { 252 | isa = PBXVariantGroup; 253 | children = ( 254 | B1D9DDC719FF6B08001615F7 /* Base */, 255 | ); 256 | name = LaunchScreen.xib; 257 | sourceTree = ""; 258 | }; 259 | /* End PBXVariantGroup section */ 260 | 261 | /* Begin XCBuildConfiguration section */ 262 | B1D9DDD519FF6B08001615F7 /* Debug */ = { 263 | isa = XCBuildConfiguration; 264 | buildSettings = { 265 | ALWAYS_SEARCH_USER_PATHS = NO; 266 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 267 | CLANG_CXX_LIBRARY = "libc++"; 268 | CLANG_ENABLE_MODULES = YES; 269 | CLANG_ENABLE_OBJC_ARC = YES; 270 | CLANG_WARN_BOOL_CONVERSION = YES; 271 | CLANG_WARN_CONSTANT_CONVERSION = YES; 272 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 273 | CLANG_WARN_EMPTY_BODY = YES; 274 | CLANG_WARN_ENUM_CONVERSION = YES; 275 | CLANG_WARN_INT_CONVERSION = YES; 276 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 277 | CLANG_WARN_UNREACHABLE_CODE = YES; 278 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 279 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 280 | COPY_PHASE_STRIP = NO; 281 | ENABLE_STRICT_OBJC_MSGSEND = YES; 282 | GCC_C_LANGUAGE_STANDARD = gnu99; 283 | GCC_DYNAMIC_NO_PIC = NO; 284 | GCC_OPTIMIZATION_LEVEL = 0; 285 | GCC_PREPROCESSOR_DEFINITIONS = ( 286 | "DEBUG=1", 287 | "$(inherited)", 288 | ); 289 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 290 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 291 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 292 | GCC_WARN_UNDECLARED_SELECTOR = YES; 293 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 294 | GCC_WARN_UNUSED_FUNCTION = YES; 295 | GCC_WARN_UNUSED_VARIABLE = YES; 296 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 297 | MTL_ENABLE_DEBUG_INFO = YES; 298 | ONLY_ACTIVE_ARCH = YES; 299 | SDKROOT = iphoneos; 300 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 301 | TARGETED_DEVICE_FAMILY = "1,2"; 302 | }; 303 | name = Debug; 304 | }; 305 | B1D9DDD619FF6B08001615F7 /* Release */ = { 306 | isa = XCBuildConfiguration; 307 | buildSettings = { 308 | ALWAYS_SEARCH_USER_PATHS = NO; 309 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 310 | CLANG_CXX_LIBRARY = "libc++"; 311 | CLANG_ENABLE_MODULES = YES; 312 | CLANG_ENABLE_OBJC_ARC = YES; 313 | CLANG_WARN_BOOL_CONVERSION = YES; 314 | CLANG_WARN_CONSTANT_CONVERSION = YES; 315 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 316 | CLANG_WARN_EMPTY_BODY = YES; 317 | CLANG_WARN_ENUM_CONVERSION = YES; 318 | CLANG_WARN_INT_CONVERSION = YES; 319 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 320 | CLANG_WARN_UNREACHABLE_CODE = YES; 321 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 322 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 323 | COPY_PHASE_STRIP = YES; 324 | ENABLE_NS_ASSERTIONS = NO; 325 | ENABLE_STRICT_OBJC_MSGSEND = YES; 326 | GCC_C_LANGUAGE_STANDARD = gnu99; 327 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 328 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 329 | GCC_WARN_UNDECLARED_SELECTOR = YES; 330 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 331 | GCC_WARN_UNUSED_FUNCTION = YES; 332 | GCC_WARN_UNUSED_VARIABLE = YES; 333 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 334 | MTL_ENABLE_DEBUG_INFO = NO; 335 | SDKROOT = iphoneos; 336 | TARGETED_DEVICE_FAMILY = "1,2"; 337 | VALIDATE_PRODUCT = YES; 338 | }; 339 | name = Release; 340 | }; 341 | B1D9DDD819FF6B08001615F7 /* Debug */ = { 342 | isa = XCBuildConfiguration; 343 | buildSettings = { 344 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 345 | INFOPLIST_FILE = SwipeBetweenViewControllers/Info.plist; 346 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 347 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 348 | PRODUCT_NAME = "$(TARGET_NAME)"; 349 | }; 350 | name = Debug; 351 | }; 352 | B1D9DDD919FF6B08001615F7 /* Release */ = { 353 | isa = XCBuildConfiguration; 354 | buildSettings = { 355 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 356 | INFOPLIST_FILE = SwipeBetweenViewControllers/Info.plist; 357 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 358 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 359 | PRODUCT_NAME = "$(TARGET_NAME)"; 360 | }; 361 | name = Release; 362 | }; 363 | B1D9DDDB19FF6B08001615F7 /* Debug */ = { 364 | isa = XCBuildConfiguration; 365 | buildSettings = { 366 | BUNDLE_LOADER = "$(TEST_HOST)"; 367 | FRAMEWORK_SEARCH_PATHS = ( 368 | "$(SDKROOT)/Developer/Library/Frameworks", 369 | "$(inherited)", 370 | ); 371 | GCC_PREPROCESSOR_DEFINITIONS = ( 372 | "DEBUG=1", 373 | "$(inherited)", 374 | ); 375 | INFOPLIST_FILE = SwipeBetweenViewControllersTests/Info.plist; 376 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 377 | PRODUCT_NAME = "$(TARGET_NAME)"; 378 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwipeBetweenViewControllers.app/SwipeBetweenViewControllers"; 379 | }; 380 | name = Debug; 381 | }; 382 | B1D9DDDC19FF6B08001615F7 /* Release */ = { 383 | isa = XCBuildConfiguration; 384 | buildSettings = { 385 | BUNDLE_LOADER = "$(TEST_HOST)"; 386 | FRAMEWORK_SEARCH_PATHS = ( 387 | "$(SDKROOT)/Developer/Library/Frameworks", 388 | "$(inherited)", 389 | ); 390 | INFOPLIST_FILE = SwipeBetweenViewControllersTests/Info.plist; 391 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 392 | PRODUCT_NAME = "$(TARGET_NAME)"; 393 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwipeBetweenViewControllers.app/SwipeBetweenViewControllers"; 394 | }; 395 | name = Release; 396 | }; 397 | /* End XCBuildConfiguration section */ 398 | 399 | /* Begin XCConfigurationList section */ 400 | B1D9DDB319FF6B08001615F7 /* Build configuration list for PBXProject "SwipeBetweenViewControllers" */ = { 401 | isa = XCConfigurationList; 402 | buildConfigurations = ( 403 | B1D9DDD519FF6B08001615F7 /* Debug */, 404 | B1D9DDD619FF6B08001615F7 /* Release */, 405 | ); 406 | defaultConfigurationIsVisible = 0; 407 | defaultConfigurationName = Release; 408 | }; 409 | B1D9DDD719FF6B08001615F7 /* Build configuration list for PBXNativeTarget "SwipeBetweenViewControllers" */ = { 410 | isa = XCConfigurationList; 411 | buildConfigurations = ( 412 | B1D9DDD819FF6B08001615F7 /* Debug */, 413 | B1D9DDD919FF6B08001615F7 /* Release */, 414 | ); 415 | defaultConfigurationIsVisible = 0; 416 | defaultConfigurationName = Release; 417 | }; 418 | B1D9DDDA19FF6B08001615F7 /* Build configuration list for PBXNativeTarget "SwipeBetweenViewControllersTests" */ = { 419 | isa = XCConfigurationList; 420 | buildConfigurations = ( 421 | B1D9DDDB19FF6B08001615F7 /* Debug */, 422 | B1D9DDDC19FF6B08001615F7 /* Release */, 423 | ); 424 | defaultConfigurationIsVisible = 0; 425 | defaultConfigurationName = Release; 426 | }; 427 | /* End XCConfigurationList section */ 428 | }; 429 | rootObject = B1D9DDB019FF6B08001615F7 /* Project object */; 430 | } 431 | -------------------------------------------------------------------------------- /SwipeBetweenViewControllers.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SwipeBetweenViewControllers/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // SwipeBetweenViewControllers 4 | // 5 | // Created by HAYAKAWA TOMOAKI on 2014/10/28. 6 | // Copyright (c) 2014年 HAYAKAWA TOMOAKI. 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: [NSObject: AnyObject]?) -> Bool { 17 | self.window = UIWindow(frame: UIScreen.mainScreen().bounds) 18 | 19 | var pageController:UIPageViewController = UIPageViewController(transitionStyle: UIPageViewControllerTransitionStyle.Scroll, navigationOrientation: UIPageViewControllerNavigationOrientation.Horizontal, options: nil) 20 | 21 | var navigationController:SwipeBetweenViewControllers = SwipeBetweenViewControllers(rootViewController: pageController) 22 | 23 | // Override point for customization after application launch. 24 | var demo:UIViewController = UIViewController() 25 | var demo2:UIViewController = UIViewController() 26 | var demo3:UIViewController = UIViewController() 27 | var demo4:UIViewController = UIViewController() 28 | var demo5:UIViewController = UIViewController() 29 | demo.view.backgroundColor = UIColor.redColor() 30 | demo2.view.backgroundColor = UIColor.whiteColor() 31 | demo3.view.backgroundColor = UIColor.grayColor() 32 | demo4.view.backgroundColor = UIColor.orangeColor() 33 | demo5.view.backgroundColor = UIColor.brownColor() 34 | 35 | navigationController.viewControllerArray = [demo,demo2,demo3,demo4,demo5] 36 | 37 | self.window?.rootViewController = navigationController 38 | self.window?.makeKeyAndVisible() 39 | return true 40 | } 41 | 42 | func applicationWillResignActive(application: UIApplication) { 43 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 44 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 45 | } 46 | 47 | func applicationDidEnterBackground(application: UIApplication) { 48 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 49 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 50 | } 51 | 52 | func applicationWillEnterForeground(application: UIApplication) { 53 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 54 | } 55 | 56 | func applicationDidBecomeActive(application: UIApplication) { 57 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 58 | } 59 | 60 | func applicationWillTerminate(application: UIApplication) { 61 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 62 | } 63 | 64 | 65 | } 66 | 67 | -------------------------------------------------------------------------------- /SwipeBetweenViewControllers/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 21 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /SwipeBetweenViewControllers/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 | -------------------------------------------------------------------------------- /SwipeBetweenViewControllers/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hayakawatomoaki/SwipeBetweenViewControllers/7b1d6013590cbb3cdc02d4e24019f589523d3828/SwipeBetweenViewControllers/Default-568h@2x.png -------------------------------------------------------------------------------- /SwipeBetweenViewControllers/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /SwipeBetweenViewControllers/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.hayatomo.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 0.0.1 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /SwipeBetweenViewControllers/SwipeBetweenViewControllers.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwipeBetweenViewControllers.swift 3 | // beacon 4 | // 5 | // Created by Richard Kim, and HAYAKAWA TOMOAKI on 2014/11/06. 6 | // Copyright (c) 2014 Richard Kim, and HAYAKAWA TOMOAKI. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | //%%% customizeable button attributes 12 | let X_BUFFER:CGFloat = 0 //%%% the number of pixels on either side of the segment 13 | let Y_BUFFER:CGFloat = 14 //%%% number of pixels on top of the segment 14 | let HEIGHT:CGFloat = 30 //%%% height of the segment 15 | 16 | //%%% customizeable selector bar attributes (the black bar under the buttons) 17 | let ANIMATION_SPEED = 0.2 //%%% the number of seconds it takes to complete the animation 18 | let SELECTOR_Y_BUFFER:CGFloat = 40 //%%% the y-value of the bar that shows what page you are on (0 is the top) 19 | let SELECTOR_HEIGHT:CGFloat = 4 //%%% thickness of the selector bar 20 | 21 | let X_OFFSET:CGFloat = 8 //%%% for some reason there's a little bit of a glitchy offset. I'm going to look for a better workaround in the future 22 | 23 | protocol SwipeBetweenViewControllersDelegate { 24 | } 25 | 26 | class SwipeBetweenViewControllers: UINavigationController,UIPageViewControllerDelegate,UIPageViewControllerDataSource,UIScrollViewDelegate 27 | { 28 | required override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) { 29 | pageScrollView = UIScrollView() 30 | pageController = UIPageViewController() 31 | navigationView = UIView() 32 | selectionBar = UIView() 33 | super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) 34 | } 35 | 36 | required init(coder aDecoder: NSCoder) { 37 | pageScrollView = UIScrollView() 38 | pageController = UIPageViewController() 39 | navigationView = UIView() 40 | selectionBar = UIView() 41 | super.init(coder: aDecoder) 42 | } 43 | 44 | required override init(rootViewController: UIViewController) { 45 | pageScrollView = UIScrollView() 46 | pageController = UIPageViewController() 47 | navigationView = UIView() 48 | selectionBar = UIView() 49 | super.init(rootViewController: rootViewController) 50 | } 51 | 52 | var pageScrollView :UIScrollView 53 | var currentPageIndex :Int = 0 54 | 55 | var viewControllerArray:[UIViewController] = [] 56 | var navDelegate:AnyObject? 57 | var selectionBar :UIView 58 | var panGestureRecognizer :UIPanGestureRecognizer? 59 | var pageController :UIPageViewController 60 | var navigationView :UIView 61 | var buttonText :[String] = [] 62 | 63 | override func viewDidLoad() { 64 | super.viewDidLoad() 65 | 66 | self.navigationBar.barTintColor = UIColor(red:0.01, green:0.05, blue:0.06, alpha:1) //%%% bartint 67 | self.navigationBar.translucent = false 68 | } 69 | 70 | //This stuff here is customizeable: buttons, views, etc 71 | //////////////////////////////////////////////////////////// 72 | //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%// 73 | //%%%%%%%%%%%%%%%%% CUSTOMIZEABLE %%%%%%%%%%%%%%%%%%// 74 | //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%// 75 | // 76 | 77 | //%%% color of the status bar 78 | override func preferredStatusBarStyle() -> UIStatusBarStyle { 79 | return UIStatusBarStyle.Default 80 | } 81 | 82 | //%%% sets up the tabs using a loop. You can take apart the loop to customize individual buttons, but remember to tag the buttons. (button.tag=0 and the second button.tag=1, etc) 83 | func setupSegmentButtons() { 84 | 85 | navigationView = UIView(frame: CGRectMake(0,0,self.view.frame.size.width,self.navigationBar.frame.size.height)) 86 | 87 | var numControllers :Int = viewControllerArray.count 88 | 89 | if (buttonText.count == 0) { 90 | buttonText = ["first","second","third","fourth","etc","etc","etc","etc"] //%%%buttontitle 91 | } 92 | 93 | for (var i = 0 ; i < numControllers; i++) { 94 | var frame :CGRect = CGRectMake(X_BUFFER+CGFloat(i)*(self.view.frame.size.width-2*X_BUFFER)/CGFloat(numControllers)-X_OFFSET, Y_BUFFER, (self.view.frame.size.width-2*X_BUFFER)/CGFloat(numControllers), HEIGHT) 95 | var button :UIButton = UIButton(frame: frame) 96 | navigationView.addSubview(button) 97 | 98 | button.tag = i //%%% IMPORTANT: if you make your own custom buttons, you have to tag them appropriately 99 | button.backgroundColor = UIColor(red: 0.03, green: 0.07, blue: 0.08, alpha: 1) //%%% buttoncolors 100 | button.addTarget(self, action: "tapSegmentButtonAction:", forControlEvents: UIControlEvents.TouchUpInside) 101 | button.setTitle(buttonText[i], forState:UIControlState.Normal) //%%%buttontitle 102 | } 103 | 104 | pageController.navigationController?.navigationBar.topItem?.titleView = navigationView 105 | 106 | self.setupSelector() 107 | } 108 | 109 | //%%% sets up the selection bar under the buttons on the navigation bar 110 | func setupSelector() { 111 | selectionBar = UIView(frame: CGRectMake(X_BUFFER-X_OFFSET, SELECTOR_Y_BUFFER,(self.view.frame.size.width-2*X_BUFFER)/CGFloat(viewControllerArray.count), SELECTOR_HEIGHT)) 112 | selectionBar.backgroundColor = UIColor.greenColor() //%%% sbcolor 113 | selectionBar.alpha = 0.8; //%%% sbalpha 114 | navigationView.addSubview(selectionBar) 115 | } 116 | 117 | // // 118 | //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%// 119 | //%%%%%%%%%%%%%%%%% CUSTOMIZEABLE %%%%%%%%%%%%%%%%%%// 120 | //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%// 121 | //////////////////////////////////////////////////////////// 122 | 123 | 124 | //generally, this shouldn't be changed unless you know what you're changing 125 | //////////////////////////////////////////////////////////// 126 | //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%// 127 | //%%%%%%%%%%%%%%%%%% SETUP %%%%%%%%%%%%%%%%%%// 128 | //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%// 129 | // // 130 | override func viewWillAppear(animated: Bool) { 131 | self.setupPageViewController() 132 | self.setupSegmentButtons() 133 | } 134 | 135 | //%%% generic setup stuff for a pageview controller. Sets up the scrolling style and delegate for the controller 136 | func setupPageViewController() { 137 | pageController = self.topViewController as! UIPageViewController 138 | pageController.delegate = self 139 | pageController.dataSource = self 140 | pageController.setViewControllers([viewControllerArray[0]], direction: UIPageViewControllerNavigationDirection.Forward, animated: true, completion: nil) 141 | self.syncScrollView() 142 | } 143 | 144 | //%%% this allows us to get information back from the scrollview, namely the coordinate information that we can link to the selection bar. 145 | func syncScrollView() { 146 | for view in pageController.view.subviews { 147 | if view.isKindOfClass(UIScrollView) { 148 | pageScrollView = view as! UIScrollView 149 | pageScrollView.delegate = self 150 | } 151 | } 152 | } 153 | 154 | // // 155 | //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%// 156 | //%%%%%%%%%%%%%%%%%% SETUP %%%%%%%%%%%%%%%%%%// 157 | //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%// 158 | //////////////////////////////////////////////////////////// 159 | 160 | 161 | //%%% methods called when you tap a button or scroll through the pages 162 | // generally shouldn't touch this unless you know what you're doing or 163 | // have a particular performance thing in mind 164 | ////////////////////////////////////////////////////////// 165 | //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%// 166 | //%%%%%%%%%%%%%%% MOVEMENT %%%%%%%%%%%%%%// 167 | //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%// 168 | // // 169 | 170 | //%%% when you tap one of the buttons, it shows that page, 171 | //but it also has to animate the other pages to make it feel like you're crossing a 2d expansion, 172 | //so there's a loop that shows every view controller in the array up to the one you selected 173 | //eg: if you're on page 1 and you click tab 3, then it shows you page 2 and then page 3 174 | func tapSegmentButtonAction(button:UIButton) { 175 | 176 | var tempIndex:Int = currentPageIndex 177 | 178 | weak var weakSelf = self 179 | 180 | //%%% check to see if you're going left -> right or right -> left 181 | if button.tag > tempIndex { 182 | //%%% scroll through all the objects between the two points 183 | for var i = tempIndex+1 ; i <= button.tag ; i++ { 184 | let index = i 185 | pageController.setViewControllers([viewControllerArray[i]], direction:UIPageViewControllerNavigationDirection.Forward, animated: true, completion: {complete in 186 | 187 | //%%% if the action finishes scrolling (i.e. the user doesn't stop it in the middle), 188 | //then it updates the page that it's currently on 189 | if complete { 190 | weakSelf?.updateCurrentPageIndex(index) 191 | } 192 | }) 193 | } 194 | } 195 | 196 | //%%% this is the same thing but for going right -> left 197 | else if button.tag < tempIndex { 198 | for var i = tempIndex-1 ; i >= button.tag ; i-- { 199 | let index = i 200 | pageController.setViewControllers([viewControllerArray[i]], direction: UIPageViewControllerNavigationDirection.Reverse, animated: true, completion: {complete in 201 | if complete { 202 | weakSelf?.updateCurrentPageIndex(index) 203 | } 204 | }) 205 | } 206 | } 207 | } 208 | 209 | //%%% makes sure the nav bar is always aware of what page you're on 210 | //in reference to the array of view controllers you gave 211 | func updateCurrentPageIndex(newIndex:Int) { 212 | currentPageIndex = newIndex 213 | } 214 | 215 | 216 | //%%% method is called when any of the pages moves. 217 | //It extracts the xcoordinate from the center point and instructs the selection bar to move accordingly 218 | func scrollViewDidScroll(scrollView: UIScrollView) { 219 | var xFromCenter:CGFloat = self.view.frame.size.width - pageScrollView.contentOffset.x //%%% positive for right swipe, negative for left 220 | 221 | //%%% checks to see what page you are on and adjusts the xCoor accordingly. 222 | //i.e. if you're on the second page, it makes sure that the bar starts from the frame.origin.x of the 223 | //second tab instead of the beginning 224 | var xCoor:CGFloat = X_BUFFER + selectionBar.frame.size.width * CGFloat(currentPageIndex) - X_OFFSET; 225 | 226 | selectionBar.frame = CGRectMake(xCoor-xFromCenter/CGFloat(viewControllerArray.count), selectionBar.frame.origin.y, selectionBar.frame.size.width, selectionBar.frame.size.height); 227 | } 228 | 229 | // // 230 | //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%// 231 | //%%%%%%%%%%%%%%% MOVEMENT %%%%%%%%%%%%%// 232 | //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%// 233 | ////////////////////////////////////////////////////////// 234 | 235 | //%%% the delegate functions for UIPageViewController. 236 | //Pretty standard, but generally, don't touch this. 237 | //////////////////////////////////////////////////////////// 238 | //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%// 239 | //%%%%%% UIPageViewController Delegate %%%%%%%// 240 | //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%// 241 | // 242 | 243 | override func didReceiveMemoryWarning() { 244 | super.didReceiveMemoryWarning() 245 | // Dispose of any resources that can be recreated. 246 | } 247 | 248 | // MARK: Page View Controller Data Source 249 | 250 | func pageViewController(pageViewController: UIPageViewController, viewControllerBeforeViewController viewController: UIViewController) -> UIViewController? { 251 | var index :Int = self.indexOfController(viewController); 252 | if (index == NSNotFound) { 253 | return nil 254 | } 255 | index-- 256 | if (0 <= index && index < viewControllerArray.count) { 257 | return viewControllerArray[index] 258 | } 259 | return nil 260 | } 261 | 262 | func pageViewController(pageViewController: UIPageViewController, viewControllerAfterViewController viewController: UIViewController) -> UIViewController? { 263 | var index :Int = self.indexOfController(viewController) 264 | if (index == NSNotFound) { 265 | return nil 266 | } 267 | index++ 268 | if (0 <= index && index < viewControllerArray.count) { 269 | return viewControllerArray[index] 270 | } 271 | return nil 272 | } 273 | 274 | func pageViewController(pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [AnyObject], transitionCompleted completed: Bool) { 275 | if (completed) { 276 | currentPageIndex = self.indexOfController(pageViewController.viewControllers.last as! UIViewController) 277 | } 278 | } 279 | 280 | //%%% checks to see which item we are currently looking at from the array of view controllers. 281 | // not really a delegate method, but is used in all the delegate methods, so might as well include it here 282 | func indexOfController(viewController :UIViewController) -> Int { 283 | for (var i = 0 ; i < viewControllerArray.count ; i++) { 284 | if (viewController == viewControllerArray[i]) { 285 | return i 286 | } 287 | } 288 | return NSNotFound 289 | } 290 | 291 | } -------------------------------------------------------------------------------- /SwipeBetweenViewControllersTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.hayatomo.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /SwipeBetweenViewControllersTests/SwipeBetweenViewControllersTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwipeBetweenViewControllersTests.swift 3 | // SwipeBetweenViewControllersTests 4 | // 5 | // Created by HAYAKAWA TOMOAKI on 2014/10/28. 6 | // Copyright (c) 2014年 HAYAKAWA TOMOAKI. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import XCTest 11 | 12 | class SwipeBetweenViewControllersTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | XCTAssert(true, "Pass") 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measureBlock() { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | --------------------------------------------------------------------------------