Skip to content

Instantly share code, notes, and snippets.

@natiginfo
Created March 11, 2022 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save natiginfo/531864b0e0a924cf764d6910133821c9 to your computer and use it in GitHub Desktop.
Save natiginfo/531864b0e0a924cf764d6910133821c9 to your computer and use it in GitHub Desktop.
import SwiftUI
struct SwipableCardsView: View {
var numbers = (1...5)
var body: some View {
GeometryReader { geo in
TabView {
ForEach(numbers, id: \.self) { i in
VStack {
Image(systemName: "\(i).circle")
.resizable()
.aspectRatio(contentMode: .fit)
.clipped()
.padding(50)
}
.frame(width: geo.size.width - 20, height: geo.size
.height / 2, alignment: .center)
.background(Color(.sRGB, red: Double.random(in: 0..<1), green: Double.random(in: 0..<1), blue: Double.random(in: 0..<1)))
.cornerRadius(20)
.shadow(radius: 10)
}
}
.tabViewStyle(PageTabViewStyle(indexDisplayMode: .automatic))
.indexViewStyle(PageIndexViewStyle(backgroundDisplayMode: .always))
}
}
}
struct SwipableCardsView_Previews: PreviewProvider {
static var previews: some View {
SwipableCardsView()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment