如何在iOS中制作这种效果,模糊效果更加精简到低端 [英] How to make this kind of effect in iOS, blur effect it is increasing leaner to lower side
本文介绍了如何在iOS中制作这种效果,模糊效果更加精简到低端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在搜索这个,但我没有找到解决我问题的确切方法,所有制作模糊效果的答案都显示在整个帧上制作模糊效果,但我希望模糊效果看起来像下面的图像
I am searched for this, but i didn't found the exact solution for my problem, all the answer for making blur effect shows making the blur effect on entire frame but i want the blur effect something look like below image
在图像中模糊效果位于底部,它越来越精简到下方
in the image the blur effect is at the bottom that to, it is increasing leaner to lower side
任何人都知道如何做这个,任何想法或示例代码... :)
can any one know how to do this, any ideas or sample code for this ... :)
推荐答案
使用 CAGradientLayer
UIColor *theColor = [[UIColor alloc] initWithRed:146.0/255.0 green:146.0/255.0 blue:146.0/255.0 alpha:1];
CAGradientLayer *gradientLayer = [CAGradientLayer layer];
CGRect gradientLayerFrame = theView.frame;
gradientLayerFrame.origin.x = 0;
gradientLayerFrame.origin.y = 0;
gradientLayer.frame = gradientLayerFrame;
//build the colors array for the gradient
NSArray *colors = [NSArray arrayWithObjects:
(id)[theColor CGColor],
(id)[[theColor colorWithAlphaComponent:0.9f] CGColor],
(id)[[theColor colorWithAlphaComponent:0.6f] CGColor],
(id)[[theColor colorWithAlphaComponent:0.4f] CGColor],
(id)[[theColor colorWithAlphaComponent:0.3f] CGColor],
(id)[[theColor colorWithAlphaComponent:0.1f] CGColor],
(id)[[UIColor clearColor] CGColor],
nil];
gradientLayer.colors = colors;
[yourView.layer insertSublayer:gradientLayer atIndex:0];
此代码的swift版本是这里
swift version of this code is here
这篇关于如何在iOS中制作这种效果,模糊效果更加精简到低端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文