Hey! I don’t know much about ViewPager, but I assume it’s similar to this in UIKit:
https://developer.apple.com/documentation/uikit/uipageviewcontroller

Unfortunately to my knowledge there isn’t a way to achieve this in SwiftUI directly. Apple’s own SwiftUI tutorial uses UIViewRepresentable to use this UIKit element, so I’ve adapted their code to make this example:

https://gist.github.com/sturdysturge/b332145793294edb504cc9a7cb9233cf

Hope it helps!

Written by

An iOS developer who writes about gadgets, startups and cybersecurity. Swift programming tutorials and SwiftUI documentation too. robsturgeon.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store