Presenting Content In Pages Using SwiftUI
Displaying paged content in SwiftUI is really a breeze
One of the tasks iOS developers often come to perform is to present paged content. That usually happens in on-boarding screens, as well as other parts in apps where users should scroll left or right to see subsequent content. Doing so in SwiftUI is surprisingly easy, especially when comparing to UIKit where things are a bit more tricky.
I have already demonstrated a related how-to in an older post on my blog, but not as a standalone topic, rather as the last part of another one. Nevertheless, it’s a programming technique that definitely deserves its own tutorial, so let’s stick just on that to find out how to show content in pages using SwiftUI.
Creating Pages
What usually indicates paged content is the appearance of a series of white dots at the bottom side of the screen, where each dot matches to a page and the selected dot is the current page. These dots are also known as the page index view.
Although that view is usually there so users have a visual feedback about the page they are in and the remaining ones, it’s also possible to make it invisible. This doesn’t change the fact, though, that the presented content is still separated in pages.