Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save SarahAlsharif/83f3cb0c0cac11478bc9cfc424ac82d4 to your computer and use it in GitHub Desktop.
Save SarahAlsharif/83f3cb0c0cac11478bc9cfc424ac82d4 to your computer and use it in GitHub Desktop.
struct likesPile : View {
@State var likes :[LikeView] = []
let timer = Timer.publish(every: 0.3, on: .main, in: .common).autoconnect()
var body: some View {
ZStack {
ForEach(likes) { like in
like.image
.resizable()
.frame(width: 50, height: 50)
.opacity(0.5)
.modifier(LikesModifier())
.padding()
}
}.onReceive(timer) { value in
if likes.count > 5 {
likes += [LikeView()]
likes.removeFirst()
} else {
likes += [LikeView()]
}
}
}
}
@peterwarbo
Copy link

Thanks!

But now where can I find the LikesModifier() ?

@SarahAlsharif
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment