UIScrollView模糊效果(UIScrollView Blur Effect)

编程入门 行业动态 更新时间:2024-10-28 11:23:36
UIScrollView模糊效果(UIScrollView Blur Effect)

我在我的项目中使用了精彩的StackBlur类,可以正常工作,但我试图创建一个类似于Yahoo Weather App的效果,其中图像根据滚动值模糊。 我已经设法使用scrollViewDidScroll方法实现它,但效果很慢并且很缓慢。

哟解决这个问题的最好方法是什么? 将图像存储到缓存是我能想到的唯一的事情。

谢谢

UPDATE

我简单地创建了两个UIImageView,其中一个带有模糊,然后将alpha设置为零,并使用scrollview中的内容偏移量增加它。

A am using the brilliant StackBlur class with in my project which works fine however I am trying to create a similar effect to the Yahoo Weather App in which the image blurs according to the scroll value. I have managed to achieve it using the scrollViewDidScroll method however the effect is slow and laggy.

What is the best way yo resolve this? Storing the image to the Cache is the only thing I can think of.

Thanks

UPDATE

I simply created two UIImageViews one with the blur and then set the alpha to zero and increased it with the content offset off the scrollview.

最满意答案

每当scrollViewDidScroll调用时都不需要模糊。 相反,您需要带有最终模糊效果的模糊图像视图,并且不要将模糊图像视图放置在模糊图像视图下方。 将模糊imageView的view.alpha从0.0更改为1.0将无需额外成本即可获得此效果。

You don't need to blur every time when scrollViewDidScroll called. Instead, you need a blurred imageView with the final blur effect and none blurred imageView placed below the blurred one. Change view.alpha of blurred imageView from 0.0 to 1.0 will get this effect without extra cost.

更多推荐

本文发布于:2023-07-29 18:22:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1318580.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:模糊   效果   UIScrollView   Blur   Effect

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!