Skip to content

Instantly share code, notes, and snippets.

@cyypherus
Created March 18, 2022 16:03
Show Gist options
  • Save cyypherus/d76d447d4bf35e96aa442acf391432fd to your computer and use it in GitHub Desktop.
Save cyypherus/d76d447d4bf35e96aa442acf391432fd to your computer and use it in GitHub Desktop.
struct ContentView: View {
struct ImageInfo: Identifiable {
let id = UUID()
let name: String
init(_ name: String) {
self.name = name
}
}
let images: [ImageInfo] = [
.init("image1"),
.init("image2"),
.init("image3"),
.init("image4"),
.init("image5")
]
var body: some View {
ZStack {
ForEach(images.indices, id: \.self) { i in
Image(images[i].name)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(height: 200)
.mask {
RollingStack() {
$0 % images.count == i
}
}
}
}
.frame(height: 200)
.clipped()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment