iOS在静态图片上滑动过滤器 [英] iOS swipe filters over static image

查看:87
本文介绍了iOS在静态图片上滑动过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种在静止图像上方滑动图像滤镜的方法。

I'm looking for a way to swipe image filters over top of a still image.

主要是基本图像保留在原位,并且滤镜在上方滑动

Mainly the base image stays in place, and the filters slide in over top when you swipe left or right.

现在,我有一个基本的UIImageView和一个Collection View,它在理论上可以容纳滤镜(纹理和渐变图像) )。

Right now I have a base UIImageView and a Collection View over top of it which in theory would hold the filters (texture and gradient images).

我已阅读到UIImageViews和UIViews不能彼此叠加在一起,并且必须在显示图像之前进行制作。因此,我可以预先在代码中预先制作图像,然后可以擦除显示过滤器图像以获得相同的效果吗?使用掩码吗?

I've read that UIImageViews and UIViews can't be live composited on top of each other, and that you must make the image before displaying it. So I can pre-make the image beforehand in code, then can I wipe-reveal the filter image to get the same effect? Using masks?

代码示例虽然不错,但是对如何实现此方法进行高级描述会有所帮助。

Code examples are nice, but a high level description on how to approach this would be helpful.

应用程序Spark具有此视频功能,我正在为照片做类似的事情。

The app Spark has this functionality for videos, I'm looking to do something similar for photos.

推荐答案


因此,我可以预先在代码中预先制作图像,然后可以擦除显示过滤器图像以获得相同的效果吗?使用面具吗?

So I can pre-make the image beforehand in code, then can I wipe-reveal the filter image to get the same effect? Using masks?

是的,但是不需要面具。预先制作过滤后的图像并将其放入图像视图。假设要从左侧向左滑动此滤镜效果。然后将图片视图的内容模式设为左,然后将其放置在实际图片的左侧,宽度为零。滑动时,将图像视图的宽度设置为图像的宽度。这将使过滤后的图像从左侧显示出来。

Yes, but no need for a mask. Pre-make the filtered image and put it in an image view. Let's say this filtered effect is to be swiped in from the left. Then make the image view's content mode be Left, and put it at the left of the real image, with width zero. As the swipe happens, animate the width of the image view to the width of the image. This will cause the filtered image to be revealed from the left side.

这篇关于iOS在静态图片上滑动过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆