21

so this is the standard way of adding filter to a layer:

NSView *view = self.window.contentView;
view.wantsLayer = YES;
CATextLayer *textLayer = [CATextLayer layer];
textLayer.frame = CGRectMake(10.0, 10.0, 200.0, 100.0);
textLayer.string = @"foo";
textLayer.foregroundColor = [[NSColor redColor] CGColor];

// Add filter
CIFilter *filter = [CIFilter filterWithName:@"CIGaussianBlur" keysAndValues:@"inputRadius", @5.0, nil];
textLayer.filters = @[filter];

// Attach layer
[view.layer addSublayer:textLayer];

However, it crashes my application on OS X Mavericks. Used to work on 10.8.

2013-10-23 13:09:20.767 Serus[3608:303] *** Terminating app due to uncaught exception 'CAInvalidCIFilter', reason: 'CI filters are not supported by this layer tree: {CIGaussianBlur {
    inputImage = "<null>";
    inputRadius = 10;
}}.'

CI filters are not supported by this layer tree

Anybody ever seen this? What may I be doing wrong?

Marek H
  • 4,264
  • 1
  • 23
  • 38
Vojto
  • 6,687
  • 4
  • 22
  • 30

1 Answers1

44

Figured it out, Apple decided to change this and require a new flag for no reason

progressIndicator.layerUsesCoreImageFilters = YES;
Brad Larson
  • 168,330
  • 45
  • 388
  • 563
user2912108
  • 717
  • 6
  • 11
  • Thanks! I had the same issue with setCompositingFilter: and this fixes it. – uliwitness Oct 27 '13 at 12:38
  • 2
    It's not for no reason, it's because by default CALayers are rendered out of process now to allow the OS to share resources better. Could certainly be documented better - may I suggest a radar :) /cc @uliwitness – Mark Aufflick Dec 27 '13 at 01:40
  • 1
    from the docs for this method... If you assign Core Image filters to your view using the setBackgroundFilters:, setCompositingFilter:, or setContentFilters: methods, you do not need to call this method explicitly. Those methods automatically let AppKit know that it needs to render the layer hierarchy in-process. – uchuugaka Jan 21 '14 at 08:19
  • 9
    It should be noted that this is a property set on the `NSView`, _not the layer_.. And for anyone interested... it is declared in the `AppKit.h` header. – Alex Gray Feb 05 '14 at 16:46
  • got stung by this one as well! – Chad Scira Sep 01 '15 at 14:38