4

It is now possible to create a horizontal scrolling page controller with the modifier:

.tabViewStyle(PageTabViewStyle())

By default, pages are presented horizontally. How can it be modified to scroll vertically the same way that UIPageViewController can?

Ardent Coder
  • 3,777
  • 9
  • 27
  • 53
Lorenzo Fiamingo
  • 3,251
  • 2
  • 17
  • 35
  • Before asking "how" you'd check "if" it is present at all. I don't see anything like it in Xcode 12 SwiftUI. – Asperi Jun 23 '20 at 12:35

2 Answers2

6

I found an efficient way to obtain this, inspired by Ernist answer.

GeometryReader { proxy in
    TabView(selection: selection) {
        everyView
            .frame(width: proxy.size.width, height: proxy.size.height)
            .rotationEffect(.degrees(-90))
            .rotation3DEffect(flippingAngle, axis: (x: 1, y: 0, z: 0))
    }
    .frame(width: proxy.size.height, height: proxy.size.width)
    .rotation3DEffect(flippingAngle, axis: (x: 1, y: 0, z: 0))
    .rotationEffect(.degrees(90), anchor: .topLeading)
    .offset(x: proxy.size.width)
}.tabViewStyle(PageTabViewStyle())

I have also built a swift package (VerticalTabView ) that gives the possibility to wrap all that code in this:

VTabView {
    everyView
}.tabViewStyle(PageTabViewStyle())
Lorenzo Fiamingo
  • 3,251
  • 2
  • 17
  • 35
2

Is this what you need

.tabViewStyle(PageTabViewStyle())
.rotationEffect(.degrees(90))
Ernist Isabekov
  • 1,205
  • 13
  • 20