Member-only story
How to: Vertical Paging in SwiftUI
How I used the TabView to build a vertical paging feed like Tik Tok.

I used the TabView
in SwiftUI to create a vertically paging feed, and here’s how you can do it too.
The TabView has a modifier called PageTabViewStyle
that allows you to turn it from a traditional tab bar into a paging scroll view. After adding this modifier, you’ll see that the view resembles UIPagingViewController
if you are familiar with UIKit. If we inspect this view under the hood, it’s actually a UICollectionView
.
The UICollectionView is using the
UICollectionViewCompositionalLayout
too, released in iOS 13, the API simplifies arranging items size like SwiftUI GridView.