Created
March 18, 2022 16:03
-
-
Save cyypherus/d76d447d4bf35e96aa442acf391432fd to your computer and use it in GitHub Desktop.
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 { | |
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