6
6
<a href="https://github.com/uias/Pageboy">
7
7
<img src="https://github.com/uias/Pageboy/workflows/Build/badge.svg" />
8
8
</a>
9
- <img src="https://img.shields.io/badge/Swift-5 -orange?logo=Swift&logoColor=white" />
9
+ <img src="https://img.shields.io/badge/Swift-6 -orange?logo=Swift&logoColor=white" />
10
10
<a href="https://github.com/uias/Pageboy/releases">
11
11
<img src="https://img.shields.io/github/release/uias/Pageboy.svg" />
12
12
</a>
15
15
</a>
16
16
</p >
17
17
18
- ** TL;DR** * UIPageViewController done properly.*
18
+ ** TL;DR** _ UIPageViewController done properly._
19
19
20
20
## ⭐️ Features
21
+
21
22
- [x] Simplified data source management & enhanced delegation.
22
23
- [x] Dynamically insert & remove pages.
23
24
- [x] Infinite scrolling support.
24
25
- [x] Automatic timer-based page transitioning.
25
26
- [x] Support for custom animated page transitions.
26
27
27
28
## 📋 Requirements
28
- Pageboy requires iOS 12 / tvOS 12; and is compatible with Swift 5.
29
+
30
+ Pageboy requires iOS 12 / tvOS 12; and is compatible with Swift 5/6.
29
31
30
32
## 📲 Installation
31
33
32
34
### Swift Package Manager
35
+
33
36
Pageboy is compatible with [ Swift Package Manager] ( https://swift.org/package-manager ) and can be integrated via Xcode.
34
37
35
38
### CocoaPods
39
+
36
40
Pageboy is also available through [ CocoaPods] ( https://cocoapods.org ) :
41
+
37
42
``` ruby
38
43
pod ' Pageboy' , ' ~> 4.2'
39
44
```
40
45
41
46
### Carthage
47
+
42
48
Pageboy is also available through [ Carthage] ( https://github.com/Carthage/Carthage ) :
49
+
43
50
``` ogdl
44
51
github "uias/Pageboy" ~> 4.2
45
52
```
46
53
47
54
## 🚀 Usage
55
+
48
56
- [ The Basics] ( #the-basics )
49
57
- [ PageboyViewControllerDelegate] ( #pageboyViewControllerDelegate )
50
58
- [ Navigation] ( #navigation )
51
59
- [ Insertion & Deletion] ( #insertion-&-deletion )
52
60
53
61
### The Basics
54
62
55
- 1 ) Create an instance of a ` PageboyViewController ` and provide it with a ` PageboyViewControllerDataSource ` .
63
+ 1 . Create an instance of a ` PageboyViewController ` and provide it with a ` PageboyViewControllerDataSource ` .
56
64
57
65
``` swift
58
66
class PageViewController : PageboyViewController , PageboyViewControllerDataSource {
59
67
60
68
override func viewDidLoad () {
61
69
super .viewDidLoad ()
62
-
70
+
63
71
self .dataSource = self
64
72
}
65
73
}
66
74
```
67
75
68
- 2 ) Implement the ` PageboyViewControllerDataSource ` functions.
76
+ 2 . Implement the ` PageboyViewControllerDataSource ` functions.
69
77
70
78
``` swift
71
79
func numberOfViewControllers (in pageboyViewController : PageboyViewController) -> Int {
@@ -87,6 +95,7 @@ func defaultPage(for pageboyViewController: PageboyViewController) -> PageboyVie
87
95
The delegate functions provided by a ` PageboyViewController ` are much more reliable and useful than what a raw ` UIPageViewController ` provides. You can use them to find out exactly where the current page is, and when it's moved, where it's headed.
88
96
89
97
#### willScrollToPageAtIndex
98
+
90
99
About to embark on a transition to a new page.
91
100
92
101
``` swift
@@ -97,6 +106,7 @@ func pageboyViewController(_ pageboyViewController: PageboyViewController,
97
106
```
98
107
99
108
#### didScrollToPosition
109
+
100
110
Scrolled to a relative position along the way transitioning to a new page.
101
111
102
112
``` swift
@@ -107,6 +117,7 @@ func pageboyViewController(_ pageboyViewController: PageboyViewController,
107
117
```
108
118
109
119
#### didScrollToPage
120
+
110
121
Successfully completed a scroll transition to a page.
111
122
112
123
``` swift
@@ -117,6 +128,7 @@ func pageboyViewController(_ pageboyViewController: PageboyViewController,
117
128
```
118
129
119
130
#### didReload
131
+
120
132
Child view controllers have been reloaded.
121
133
122
134
``` swift
@@ -126,7 +138,9 @@ func pageboyViewController(_ pageboyViewController: PageboyViewController,
126
138
```
127
139
128
140
### Navigation
141
+
129
142
You can navigate programmatically through a ` PageboyViewController ` using ` scrollToPage() ` :
143
+
130
144
``` swift
131
145
pageViewController.scrollToPage (.next , animated : true )
132
146
```
@@ -135,14 +149,15 @@ pageViewController.scrollToPage(.next, animated: true)
135
149
- Interactive scrolling can also be controlled with ` .isScrollEnabled ` .
136
150
137
151
### Insertion & Deletion
152
+
138
153
Pageboy provides the ability to insert and delete pages dynamically in the ` PageboyViewController ` .
139
154
140
155
``` swift
141
156
func insertPage (at index : PageIndex, then updateBehavior : PageUpdateBehavior)
142
157
func deletePage (at index : PageIndex, then updateBehavior : PageUpdateBehavior)
143
158
```
144
159
145
- * This behaves similarly to the insertion of rows in ` UITableView ` , in the fact that you have to update the data source prior to calling any of the update functions.*
160
+ _ This behaves similarly to the insertion of rows in ` UITableView ` , in the fact that you have to update the data source prior to calling any of the update functions._
146
161
147
162
** Example:**
148
163
@@ -152,7 +167,7 @@ viewControllers.insert(UIViewController(), at: index)
152
167
pageViewController.insertPage (at : index)
153
168
```
154
169
155
- * The default behavior after inserting or deleting a page is to scroll to the update location, this however can be configured by passing a ` PageUpdateBehavior ` value other than ` .scrollToUpdate ` .*
170
+ _ The default behavior after inserting or deleting a page is to scroll to the update location, this however can be configured by passing a ` PageUpdateBehavior ` value other than ` .scrollToUpdate ` ._
156
171
157
172
## ⚡️ Other Extras
158
173
@@ -164,15 +179,17 @@ pageViewController.insertPage(at: index)
164
179
- ` .parentPageboy ` - Access the immediate parent ` PageboyViewController ` from any child view controller.
165
180
166
181
### Animated Transitions
182
+
167
183
Pageboy also provides custom transition support for ** animated transitions** . This can be customized via the ` .transition ` property on ` PageboyViewController ` .
168
184
169
185
``` swift
170
186
pageboyViewController.transition = Transition (style : .push , duration : 1.0 )
171
187
```
172
188
173
- * Note : By default this is set to ` nil ` , which uses the standard animation provided by ` UIPageViewController ` .*
189
+ _ Note : By default this is set to ` nil ` , which uses the standard animation provided by ` UIPageViewController ` ._
174
190
175
191
### Auto Scrolling
192
+
176
193
` PageboyAutoScroller ` is available to set up timer based automatic scrolling of the ` PageboyViewController ` :
177
194
178
195
``` swift
@@ -182,11 +199,14 @@ pageboyViewController.autoScroller.enable()
182
199
Support for custom intermission duration and other scroll behaviors is also available.
183
200
184
201
## 👨🏻💻 About
202
+
185
203
- Created by [ Merrick Sapsford] ( https://github.com/msaps ) ([ @MerrickSapsford ] ( https://twitter.com/MerrickSapsford ) )
186
204
- Contributed to by a growing [ list of others] ( https://github.com/uias/Pageboy/graphs/contributors ) .
187
205
188
206
## ❤️ Contributing
207
+
189
208
Bug reports and pull requests are welcome on GitHub at [ https://github.com/uias/Pageboy ] ( https://github.com/uias/Pageboy ) .
190
209
191
210
## 👮🏻♂️ License
211
+
192
212
The library is available as open source under the terms of the [ MIT License] ( https://opensource.org/licenses/MIT ) .
0 commit comments