Matt Buckley
Nice Things | iOS + Android Development
1 min readMar 17, 2020

--

Before SwiftUIcame along, UIPageControl was the obvious choice for putting together a typical paginated onboarding sequence. We can still integrate UIKitclasses into SwiftUIeasily enough, but having a first party implementation within the framework is preferable.

We sought to keep things as simple as possible with our implementation, but as you can see there’s still a fair amount of tricky state management to take care of.

At a high level, our PaginatedViewjust contains an HStack, which contains each constituent “page” of our page control. We attach a DragGestureto the PaginatedView, which it uses to set the appropriate index of the current page. Finally, the PaginatedViewpasses data down to a DotsComponent, which highlights the appropriate dot.

--

--