Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use a CIFilter on the layerClass instance of an UIView?

My UIView is using an instance of TBPaperLayer for its layer.

+(Class)layerClass {
    return [TBPaperLayer class];
}

I would like to create a CIFilter to modify the appearance of this layer - especially apply a blur filter on it. How can I use this code to blur a part of this layer ? (code from: Blur CALayer's Superlayer)

CALayer *blurLayer = [CALayer layer];
CIFilter *blur = [CIFilter filterWithName:@"CIGaussianBlur"];
[blur setDefaults];
blurLayer.backgroundFilters = [NSArray arrayWithObject:blur];
[self.superlayer addSublayer:blurLayer];

There is no superlayer during -init.

like image 484
alecail Avatar asked Dec 21 '22 07:12

alecail


1 Answers

This is not possible on iOS. From the CALayer class reference:

Special Considerations

This property is not supported on layers in iOS.

Presumably Apple don't feel that the current generation of iOS hardware is powerful enough to support live image filtering.

like image 145
jrturton Avatar answered Dec 28 '22 07:12

jrturton