Skip to content

Instantly share code, notes, and snippets.

@gtokman
Last active March 10, 2021 04:53
Show Gist options
  • Save gtokman/f62ad19b4ce421946bb448b3c6f866c9 to your computer and use it in GitHub Desktop.
Save gtokman/f62ad19b4ce421946bb448b3c6f866c9 to your computer and use it in GitHub Desktop.
Vertical paging with TabView
struct ContentView: View {
let colors: [Color] = [
.red, .green, .blue, .gray
]
var body: some View {
GeometryReader { proxy in
TabView {
ForEach(colors, id: \.self) { color in
color // Your cell content
}
.rotationEffect(.degrees(-90)) // Rotate content
.frame(
width: proxy.size.width,
height: proxy.size.height
)
}
.frame(
width: proxy.size.height, // Height & width swap
height: proxy.size.width
)
.rotationEffect(.degrees(90), anchor: .topLeading) // Rotate TabView
.offset(x: proxy.size.width) // Offset back into screens bounds
.tabViewStyle(
PageTabViewStyle(indexDisplayMode: .never)
)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment