Last active
March 10, 2021 04:53
-
-
Save gtokman/f62ad19b4ce421946bb448b3c6f866c9 to your computer and use it in GitHub Desktop.
Vertical paging with TabView
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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