Skip to content
A custom ScrollView wrapper that comes with Pagination and Page Control.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
SwiftyUIScrollView Some fixes Aug 19, 2019 Update Aug 19, 2019


A custom ScrollView wrapper that comes with Pagination and Page Control.

Wrap HStack or VStack with the custom SwiftUIScrollView to get pagination and page control features. The initializer for the wrapper is:

init(axis: DirectionX, numberOfPages: Int,
         pagingEnabled: Bool,
         pageControlEnabled: Bool,
         hideScrollIndicators: Bool,
         currentPageIndicator: UIColor?,
         pageIndicatorTintColor: UIColor?,
         @ViewBuilder content: @escaping () -> Content)

This is how the above custom wrapper could be used:

SwiftyUIScrollView(axis: .horizontal, numberOfPages: self.contentArray.count, pagingEnabled: true, pageControlEnabled: true, hideScrollIndicators: true) {
                    HStack(spacing: 0) {
                        ForEach(self.contentArray, id: \.id) { item in
                            TestView(data: item)
                                    .frame(width: g.size.width, height: g.size.height)
            }.frame(width: g.size.width)

The DirectionX enum contains two directions:

enum DirectionX {
    case horizontal
    case vertical

If you are using HStack, make sure you set the axis in initializer to- .horizontal, if using VStack make sure you use .vertical. This is madatory in order to have pagination and page controls to work for both directions.

You can’t perform that action at this time.