21

所以这是向图层添加过滤器的标准方法:

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];

但是,它使我的应用程序在 OS X Mavericks 上崩溃。曾经在 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 过滤器

有人见过这个吗?我可能做错了什么?

4

1 回答 1

45

想通了,苹果决定改变这一点,无缘无故地要求一个新的标志

progressIndicator.layerUsesCoreImageFilters = YES;
于 2013-10-23T15:36:00.297 回答