Search code examples
iosswiftuipageviewcontroller

How to make UIPageViewController show current and next cell simultaneously


My app use UIPageViewController to implement swipe card like this enter image description here

Now I would like to implement swipe card like below, it shows part of next cell enter image description here

Is there any way using UIPageViewController to implement swipe card like the second image?


Solution

  • import SwiftUI
    
    struct OnboardingView: View {
    
        var fruits: [Fruit] = fruitsData
    
        var body: some View {
            TabView {
                ForEach(fruits[0...5]) { item in
                    FruitCardView(fruit: item)
                } // Loop
            } // Tab
            .tabViewStyle(PageTabViewStyle())
            .padding(.vertical, 20)
        }
    }
    
    struct OnboardingView_Previews: PreviewProvider {
        static var previews: some View {
            OnboardingView(fruits: fruitsData)
        }
    }
    

    **You can try this here is a tabview which have 5 card that can be swipe there is a FruitCardView(fruit: item) is just a card view which had image and text.

    ------------------ or -------------------

    If you are working in swift then you can use collection view there scroll is enable in horizontal axis**