模糊CALayer的上层 [英] Blur CALayer's Superlayer
本文介绍了模糊CALayer的上层的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个CALayer和一个子图层。我想实现的是超级模糊(子层下面的区域),就像标准的工作表一样。我试图在子图层上设置 .compositingFilter ,但这似乎不起作用。
I've got a CALayer and a sublayer in it. What i want to achieve is a blur of the superlayer (the area under the sublayer), just like the standard sheets do it. I've tried to set a .compositingFilter on the sublayer but this doesn't seem to work.
任何想法如何解决这个问题?
Any ideas how to solve this?
子层中的代码init:
Code from the sublayers init:
CIFilter *blur = [CIFilter filterWithName:@"CIGaussianBlur"];
[blur setDefaults];
self.layer.backgroundFilters = [NSArray arrayWithObject:blur];
推荐答案
上述应该工作正常,用于包含图像的简单超图层,以下适用于我:
The above should work fine, depending on the context it is used in. E.g. with a simple super-layer containing an image, the following works for me:
CALayer *blurLayer = [CALayer layer];
CIFilter *blur = [CIFilter filterWithName:@"CIGaussianBlur"];
[blur setDefaults];
blurLayer.backgroundFilters = [NSArray arrayWithObject:blur];
[superLayer addSublayer:blurLayer];
这篇关于模糊CALayer的上层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文