-
-
Notifications
You must be signed in to change notification settings - Fork 437
Pagination
Vatsal Manot edited this page Dec 10, 2019
·
5 revisions
SwiftUIX offers a port of UIPageViewController
via PaginationView
.
/// A view that paginates its children along a given axis.
public struct PaginationView<Content: View>: View {
public init(
axis: Axis = .horizontal,
pageIndicatorAlignment: Alignment? = nil,
@ArrayBuilder<Page> content: () -> [Page]
)
/// Declares the content and behavior of this view.
public var body: some View { get }
}
One notable feature of the port offered by SwiftUIX is that it offers page indicators for both horizontal and vertical pagination.
struct ContentView: View {
var body: some View {
PaginationView(axis: .horizontal) {
Text("One")
Text("Two")
Text("Three")
}
}
}
Note that the views must be homogeneous. If you wish to mix multiple view types, ensure that they are erased to AnyView
via View.eraseToAnyView()
provided by SwiftUIX:
struct ContentView: View {
var body: some View {
PaginationView(axis: .horizontal) {
ViewTypeOne().eraseToAnyView()
ViewTypeTwo().eraseToAnyView()
ViewTypeThree().eraseToAnyView()
}
}
}
If you see any problems with the content above, please file an issue here.