使用 CAReplicatorLayer 实现下雪效果
我有一个雪花图像,我想在屏幕上复制并创建降雪。我们可以将instanceCount设置为X来创建大量雪花,并且可以设置instanceTransform以使每个实例与下一个实例保持一定距离。
但我不知道如何让它们掉下来。有谁知道这个类是否打算用于类似的事情,如果是的话应该如何正确完成?
I have a single snowflake image that I would like to replicate and create snowfall on the screen. We can set the instanceCount to X to create a large number of snowflakes and we can set the instanceTransform to put each instance some distance from the next.
However I am not clear how to make them fall down. Does anyone understands if this class was intended to be used for something like this and if so how should it be properly done?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将动画应用到原始子图层......所有复制的图层都遵循相同的动画,并通过instanceDelay 和instanceTransform 属性进行调整。
希望这有帮助!
You apply the animation to the original sublayer.... all the replicated layers follow the same animation, adjusted by the instanceDelay and instanceTransform properties.
Hope this helps!