如何在swiftui中对核心图像过滤器进行动画动画
我想应用一个给定的cifilter,但我想对其进行动画效果,而不是立即出现的效果。例如,我想在2秒内将颜色图像保留为灰度,或通过将其放松的动画曲线超过0.8秒将其深入到完整的图像来解决块状图像。
如果您使用的是内置的SwiftUi视图修饰符,例如.blur(),那么您是金色的。只需附加一些.ainimate()变体,就完成了。
但是,鉴于您必须跳过篮球,无论您是使用UIImage,CGIMAGE,CIIMAGE路线还是MTLView,CirenderDestination,ContentView from wwdc 2022示例代码,我有点困惑。
理想情况下,我想我只想为我想做的每种效果编写视图修饰符,以便它们与Swiftui内置的效果一样可用,但是我不知道这是否可能。这样做有幸福的方式吗?有什么想法吗?
I want to apply a given CIFilter but instead of the effect showing up instantly, I want to animate it. For example, I want to desaturate a color image to grey scale over 2 seconds, or resolve a blocky image by depixellating it to a full-resolution image using an EaseInOut animation curve over 0.8 seconds.
If you're using one of the built in SwiftUI view modifiers like .blur(), you're golden. Just append some .animate() variant and you're done.
But given that you have to jump through hoops whether you go the UIImage, CGImage, CIImage route, or the MTLView, CIRenderDestination, ContentView example from the WWDC 2022 sample code, I'm a bit confused.
Ideally I guess I'd just like to write View Modifiers for each effect I want to do, so that they're as usable as the SwiftUI built-in ones, but I don't know if that's possible. Is there one blessed way of doing this? Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一种方法适应
动画
。您可以轻松地适应您的需求:Here is an approach adapting
Animatable
. You can easily adapt it to your needs: