Skip to content
This repository was archived by the owner on May 8, 2025. It is now read-only.

Commit 0f594a2

Browse files
author
Oscar Apeland
committed
Initial commit
1 parent 4999579 commit 0f594a2

18 files changed

+820
-99
lines changed

SwipingViewController.podspec

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Pod::Spec.new do |s|
2+
s.name = 'SwipeableViewController'
3+
s.version = '0.1.0'
4+
s.summary = 'A small UI component to build UIPageViewController-y views in your app.'
5+
6+
s.description = <<-DESC
7+
A segmented header and a UIPageViewController all in one convenient package.
8+
DESC
9+
10+
s.homepage = 'https://github.com/tiseoslo/SwipeableViewController'
11+
s.license = { :type => 'MIT', :file => 'LICENSE' }
12+
s.author = { 'Oscar Apeland' => 'oscar@tiseit.com' }
13+
s.source = { :git => 'https://github.com/tiseoslo/SwipeableViewController.git', :tag => s.version.to_s }
14+
15+
s.ios.deployment_target = '10.0'
16+
s.source_files = 'SwipeableViewController/Source/*.swift'
17+
18+
end

SwipingViewController.xcodeproj/project.pbxproj

Lines changed: 70 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,36 @@
88

99
/* Begin PBXBuildFile section */
1010
08254DD81F8E9EDA006DD969 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08254DD71F8E9EDA006DD969 /* AppDelegate.swift */; };
11-
08254DDA1F8E9EDA006DD969 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08254DD91F8E9EDA006DD969 /* ViewController.swift */; };
12-
08254DDD1F8E9EDA006DD969 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 08254DDB1F8E9EDA006DD969 /* Main.storyboard */; };
1311
08254DDF1F8E9EDA006DD969 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 08254DDE1F8E9EDA006DD969 /* Assets.xcassets */; };
1412
08254DE21F8E9EDA006DD969 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 08254DE01F8E9EDA006DD969 /* LaunchScreen.storyboard */; };
13+
087E9B1C1F90C336007DCB8F /* ExampleSwipeableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 087E9B1B1F90C336007DCB8F /* ExampleSwipeableViewController.swift */; };
14+
08A9E2DB1F9E2FF8000B2729 /* SwipeableNavigationBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08A9E2D31F9E2FF8000B2729 /* SwipeableNavigationBar.swift */; };
15+
08A9E2DC1F9E2FF8000B2729 /* SwipeableItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08A9E2D41F9E2FF8000B2729 /* SwipeableItem.swift */; };
16+
08A9E2DD1F9E2FF8000B2729 /* SwipeableCollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08A9E2D51F9E2FF8000B2729 /* SwipeableCollectionView.swift */; };
17+
08A9E2DE1F9E2FF8000B2729 /* SwipeableCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08A9E2D61F9E2FF8000B2729 /* SwipeableCell.swift */; };
18+
08A9E2DF1F9E2FF8000B2729 /* SwipeableNavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08A9E2D71F9E2FF8000B2729 /* SwipeableNavigationController.swift */; };
19+
08A9E2E01F9E2FF8000B2729 /* SwipeableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08A9E2D81F9E2FF8000B2729 /* SwipeableViewController.swift */; };
20+
08A9E2E11F9E2FF8000B2729 /* SwipeableCollectionViewFlowLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08A9E2D91F9E2FF8000B2729 /* SwipeableCollectionViewFlowLayout.swift */; };
21+
08A9E2E21F9E2FF8000B2729 /* SwipeableCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 08A9E2DA1F9E2FF8000B2729 /* SwipeableCell.xib */; };
22+
08D04A631F8F959100982B4C /* ExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08D04A621F8F959100982B4C /* ExampleViewController.swift */; };
1523
/* End PBXBuildFile section */
1624

1725
/* Begin PBXFileReference section */
1826
08254DD41F8E9EDA006DD969 /* SwipingViewController.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwipingViewController.app; sourceTree = BUILT_PRODUCTS_DIR; };
1927
08254DD71F8E9EDA006DD969 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
20-
08254DD91F8E9EDA006DD969 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
21-
08254DDC1F8E9EDA006DD969 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
2228
08254DDE1F8E9EDA006DD969 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
2329
08254DE11F8E9EDA006DD969 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
2430
08254DE31F8E9EDA006DD969 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
31+
087E9B1B1F90C336007DCB8F /* ExampleSwipeableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleSwipeableViewController.swift; sourceTree = "<group>"; };
32+
08A9E2D31F9E2FF8000B2729 /* SwipeableNavigationBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwipeableNavigationBar.swift; sourceTree = "<group>"; };
33+
08A9E2D41F9E2FF8000B2729 /* SwipeableItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwipeableItem.swift; sourceTree = "<group>"; };
34+
08A9E2D51F9E2FF8000B2729 /* SwipeableCollectionView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwipeableCollectionView.swift; sourceTree = "<group>"; };
35+
08A9E2D61F9E2FF8000B2729 /* SwipeableCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwipeableCell.swift; sourceTree = "<group>"; };
36+
08A9E2D71F9E2FF8000B2729 /* SwipeableNavigationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwipeableNavigationController.swift; sourceTree = "<group>"; };
37+
08A9E2D81F9E2FF8000B2729 /* SwipeableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwipeableViewController.swift; sourceTree = "<group>"; };
38+
08A9E2D91F9E2FF8000B2729 /* SwipeableCollectionViewFlowLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwipeableCollectionViewFlowLayout.swift; sourceTree = "<group>"; };
39+
08A9E2DA1F9E2FF8000B2729 /* SwipeableCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SwipeableCell.xib; sourceTree = "<group>"; };
40+
08D04A621F8F959100982B4C /* ExampleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleViewController.swift; sourceTree = "<group>"; };
2541
/* End PBXFileReference section */
2642

2743
/* Begin PBXFrameworksBuildPhase section */
@@ -35,6 +51,26 @@
3551
/* End PBXFrameworksBuildPhase section */
3652

3753
/* Begin PBXGroup section */
54+
080FFF321F9797BE00DF7612 /* Junk */ = {
55+
isa = PBXGroup;
56+
children = (
57+
08254DDE1F8E9EDA006DD969 /* Assets.xcassets */,
58+
08254DE01F8E9EDA006DD969 /* LaunchScreen.storyboard */,
59+
08254DE31F8E9EDA006DD969 /* Info.plist */,
60+
08254DD71F8E9EDA006DD969 /* AppDelegate.swift */,
61+
);
62+
name = Junk;
63+
sourceTree = "<group>";
64+
};
65+
080FFF331F9797CB00DF7612 /* Example */ = {
66+
isa = PBXGroup;
67+
children = (
68+
08D04A621F8F959100982B4C /* ExampleViewController.swift */,
69+
087E9B1B1F90C336007DCB8F /* ExampleSwipeableViewController.swift */,
70+
);
71+
name = Example;
72+
sourceTree = "<group>";
73+
};
3874
08254DCB1F8E9EDA006DD969 = {
3975
isa = PBXGroup;
4076
children = (
@@ -54,16 +90,28 @@
5490
08254DD61F8E9EDA006DD969 /* SwipingViewController */ = {
5591
isa = PBXGroup;
5692
children = (
57-
08254DD71F8E9EDA006DD969 /* AppDelegate.swift */,
58-
08254DD91F8E9EDA006DD969 /* ViewController.swift */,
59-
08254DDB1F8E9EDA006DD969 /* Main.storyboard */,
60-
08254DDE1F8E9EDA006DD969 /* Assets.xcassets */,
61-
08254DE01F8E9EDA006DD969 /* LaunchScreen.storyboard */,
62-
08254DE31F8E9EDA006DD969 /* Info.plist */,
93+
08A9E2D21F9E2FF8000B2729 /* Source */,
94+
080FFF321F9797BE00DF7612 /* Junk */,
95+
080FFF331F9797CB00DF7612 /* Example */,
6396
);
6497
path = SwipingViewController;
6598
sourceTree = "<group>";
6699
};
100+
08A9E2D21F9E2FF8000B2729 /* Source */ = {
101+
isa = PBXGroup;
102+
children = (
103+
08A9E2D31F9E2FF8000B2729 /* SwipeableNavigationBar.swift */,
104+
08A9E2D41F9E2FF8000B2729 /* SwipeableItem.swift */,
105+
08A9E2D51F9E2FF8000B2729 /* SwipeableCollectionView.swift */,
106+
08A9E2D61F9E2FF8000B2729 /* SwipeableCell.swift */,
107+
08A9E2D71F9E2FF8000B2729 /* SwipeableNavigationController.swift */,
108+
08A9E2D81F9E2FF8000B2729 /* SwipeableViewController.swift */,
109+
08A9E2D91F9E2FF8000B2729 /* SwipeableCollectionViewFlowLayout.swift */,
110+
08A9E2DA1F9E2FF8000B2729 /* SwipeableCell.xib */,
111+
);
112+
path = Source;
113+
sourceTree = "<group>";
114+
};
67115
/* End PBXGroup section */
68116

69117
/* Begin PBXNativeTarget section */
@@ -124,8 +172,8 @@
124172
buildActionMask = 2147483647;
125173
files = (
126174
08254DE21F8E9EDA006DD969 /* LaunchScreen.storyboard in Resources */,
175+
08A9E2E21F9E2FF8000B2729 /* SwipeableCell.xib in Resources */,
127176
08254DDF1F8E9EDA006DD969 /* Assets.xcassets in Resources */,
128-
08254DDD1F8E9EDA006DD969 /* Main.storyboard in Resources */,
129177
);
130178
runOnlyForDeploymentPostprocessing = 0;
131179
};
@@ -136,22 +184,22 @@
136184
isa = PBXSourcesBuildPhase;
137185
buildActionMask = 2147483647;
138186
files = (
139-
08254DDA1F8E9EDA006DD969 /* ViewController.swift in Sources */,
187+
08A9E2DE1F9E2FF8000B2729 /* SwipeableCell.swift in Sources */,
188+
08A9E2DC1F9E2FF8000B2729 /* SwipeableItem.swift in Sources */,
189+
08A9E2E01F9E2FF8000B2729 /* SwipeableViewController.swift in Sources */,
190+
08A9E2DD1F9E2FF8000B2729 /* SwipeableCollectionView.swift in Sources */,
191+
08A9E2DF1F9E2FF8000B2729 /* SwipeableNavigationController.swift in Sources */,
192+
08A9E2E11F9E2FF8000B2729 /* SwipeableCollectionViewFlowLayout.swift in Sources */,
193+
08A9E2DB1F9E2FF8000B2729 /* SwipeableNavigationBar.swift in Sources */,
140194
08254DD81F8E9EDA006DD969 /* AppDelegate.swift in Sources */,
195+
08D04A631F8F959100982B4C /* ExampleViewController.swift in Sources */,
196+
087E9B1C1F90C336007DCB8F /* ExampleSwipeableViewController.swift in Sources */,
141197
);
142198
runOnlyForDeploymentPostprocessing = 0;
143199
};
144200
/* End PBXSourcesBuildPhase section */
145201

146202
/* Begin PBXVariantGroup section */
147-
08254DDB1F8E9EDA006DD969 /* Main.storyboard */ = {
148-
isa = PBXVariantGroup;
149-
children = (
150-
08254DDC1F8E9EDA006DD969 /* Base */,
151-
);
152-
name = Main.storyboard;
153-
sourceTree = "<group>";
154-
};
155203
08254DE01F8E9EDA006DD969 /* LaunchScreen.storyboard */ = {
156204
isa = PBXVariantGroup;
157205
children = (
@@ -277,6 +325,7 @@
277325
CODE_SIGN_STYLE = Automatic;
278326
DEVELOPMENT_TEAM = 88F3596FP2;
279327
INFOPLIST_FILE = SwipingViewController/Info.plist;
328+
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
280329
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
281330
PRODUCT_BUNDLE_IDENTIFIER = Tise.SwipingViewController;
282331
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -292,6 +341,7 @@
292341
CODE_SIGN_STYLE = Automatic;
293342
DEVELOPMENT_TEAM = 88F3596FP2;
294343
INFOPLIST_FILE = SwipingViewController/Info.plist;
344+
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
295345
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
296346
PRODUCT_BUNDLE_IDENTIFIER = Tise.SwipingViewController;
297347
PRODUCT_NAME = "$(TARGET_NAME)";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Bucket
3+
type = "1"
4+
version = "2.0">
5+
<Breakpoints>
6+
<BreakpointProxy
7+
BreakpointExtensionID = "Xcode.Breakpoint.SwiftErrorBreakpoint">
8+
<BreakpointContent
9+
shouldBeEnabled = "Yes"
10+
ignoreCount = "0"
11+
continueAfterRunningActions = "No">
12+
</BreakpointContent>
13+
</BreakpointProxy>
14+
<BreakpointProxy
15+
BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
16+
<BreakpointContent
17+
shouldBeEnabled = "Yes"
18+
ignoreCount = "0"
19+
continueAfterRunningActions = "No"
20+
scope = "0"
21+
stopOnStyle = "0">
22+
</BreakpointContent>
23+
</BreakpointProxy>
24+
</Breakpoints>
25+
</Bucket>
Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
//
23
// AppDelegate.swift
34
// SwipingViewController
@@ -10,37 +11,22 @@ import UIKit
1011

1112
@UIApplicationMain
1213
class AppDelegate: UIResponder, UIApplicationDelegate {
13-
1414
var window: UIWindow?
1515

16-
1716
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
18-
// Override point for customization after application launch.
19-
return true
20-
}
21-
22-
func applicationWillResignActive(_ application: UIApplication) {
23-
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
24-
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
25-
}
26-
27-
func applicationDidEnterBackground(_ application: UIApplication) {
28-
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
29-
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
30-
}
17+
window = UIWindow(frame: UIScreen.main.bounds)
18+
19+
let navigationController = SwipeableNavigationController(navigationBarClass: SwipeableNavigationBar.self, toolbarClass: nil)
20+
let viewController = ExampleSwipeableViewController()
21+
viewController.swipeableItems = [SwipeableItem(title: "Recent", viewController: ExampleViewController()),
22+
SwipeableItem(title: "Explore", viewController: ExampleViewController()),
23+
SwipeableItem(title: "Browse", viewController: ExampleViewController())]
24+
viewController.selectedIndex = 1
25+
navigationController.setViewControllers([viewController], animated: false)
26+
27+
window?.rootViewController = navigationController
28+
window?.makeKeyAndVisible()
3129

32-
func applicationWillEnterForeground(_ application: UIApplication) {
33-
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
34-
}
35-
36-
func applicationDidBecomeActive(_ application: UIApplication) {
37-
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
38-
}
39-
40-
func applicationWillTerminate(_ application: UIApplication) {
41-
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
30+
return true
4231
}
43-
44-
4532
}
46-

SwipingViewController/Assets.xcassets/AppIcon.appiconset/Contents.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@
8484
"idiom" : "ipad",
8585
"size" : "83.5x83.5",
8686
"scale" : "2x"
87+
},
88+
{
89+
"idiom" : "ios-marketing",
90+
"size" : "1024x1024",
91+
"scale" : "1x"
8792
}
8893
],
8994
"info" : {

SwipingViewController/Base.lproj/Main.storyboard

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//
2+
// ExampleSwipeableViewController.swift
3+
// SwipingViewController
4+
//
5+
// Created by Oscar Apeland on 13.10.2017.
6+
// Copyright © 2017 Tise. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
class ExampleSwipeableViewController: SwipeableViewController {
12+
lazy var searchController = UISearchController(searchResultsController: {
13+
$0.view.backgroundColor = .red
14+
return $0
15+
}(UIViewController()))
16+
17+
override func viewDidLoad() {
18+
super.viewDidLoad()
19+
if #available(iOS 11.0, *) {
20+
navigationItem.searchController = searchController
21+
} else {
22+
navigationItem.titleView = searchController.searchBar
23+
}
24+
definesPresentationContext = true
25+
}
26+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
//
2+
// ExampleViewController.swift
3+
// SwipingViewController
4+
//
5+
// Created by Oscar Apeland on 12.10.2017.
6+
// Copyright © 2017 Tise. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
class ExampleViewController: UIViewController {
12+
lazy var collectionView: UICollectionView = {
13+
$0.backgroundColor = .white
14+
$0.alwaysBounceVertical = true
15+
$0.delegate = self
16+
$0.dataSource = self
17+
$0.autoresizingMask = [.flexibleHeight, .flexibleWidth]
18+
($0.collectionViewLayout as? UICollectionViewFlowLayout)?.sectionInset = UIEdgeInsets(top: 20, left: 0, bottom: 0, right: 0)
19+
20+
return $0
21+
}(UICollectionView(frame: view.bounds, collectionViewLayout: UICollectionViewFlowLayout()))
22+
23+
let cellColor = UIColor.random
24+
25+
override func viewDidLoad() {
26+
super.viewDidLoad()
27+
view.addSubview(collectionView)
28+
if #available(iOS 11.0, *) {
29+
collectionView.contentInsetAdjustmentBehavior = .always
30+
}
31+
}
32+
}
33+
34+
extension ExampleViewController: UICollectionViewDataSource, UICollectionViewDelegate {
35+
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
36+
return 100
37+
}
38+
39+
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
40+
collectionView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: "cell")
41+
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath)
42+
cell.backgroundColor = cellColor
43+
44+
return cell
45+
}
46+
47+
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
48+
let vc = UICollectionViewController(collectionViewLayout: UICollectionViewFlowLayout())
49+
50+
vc.collectionView?.backgroundColor = .white
51+
vc.collectionView?.dataSource = self
52+
vc.collectionView?.delegate = self
53+
54+
navigationController?.pushViewController(vc, animated: true)
55+
}
56+
}
57+
58+
extension UIColor {
59+
class var random: UIColor {
60+
func random() -> CGFloat {
61+
return CGFloat(arc4random()) / CGFloat(UInt32.max)
62+
}
63+
64+
return UIColor(red: random(), green: random(), blue: random(), alpha: 1.0)
65+
}
66+
}

0 commit comments

Comments
 (0)