0

我正在使用它[CIFilter filterNamesInCategories:nil]来获取可用过滤器的列表,但是如何获取类别列表?我当然可以枚举过滤器列表,并阅读每个过滤器中的类别来构建一个集合,但是有更好的方法吗?

4

3 回答 3

2

这是我的做法:

NSMutableSet  * categories = [NSMutableSet set];
for (NSString* filterName in [CIFilter filterNamesInCategories:nil])
{
    for (id value in  [[[CIFilter filterWithName:filterName] attributes] 
    valueForKey:@"CIAttributeFilterCategories"]) {
        [categories addObject:value];
    }
}
NSLog(@"%@", categories);
于 2013-04-04T08:54:56.470 回答
1

Swift 4.2 版本在这里。

  import CoreImage

  var results = NSMutableSet()
  let categories = CIFilter.filterNames(inCategory: nil)

  for category in categories {
      let attributes = CIFilter(name: category)?.attributes
      let filterCategories = attributes!["CIAttributeFilterCategories"]
      results.addObjects(from: filterCategories as! [Any])
  }

  print(results)
于 2018-10-22T20:19:47.883 回答
0

这是来自文档:

过滤类别键

过滤器类别。

extern NSString *kCICategoryDistortionEffect;
extern NSString *kCICategoryGeometryAdjustment;
extern NSString *kCICategoryCompositeOperation;
extern NSString *kCICategoryHalftoneEffect;
extern NSString *kCICategoryColorAdjustment;
extern NSString *kCICategoryColorEffect;
extern NSString *kCICategoryTransition;
extern NSString *kCICategoryTileEffect;
extern NSString *kCICategoryGenerator;
extern NSString *kCICategoryReduction;
extern NSString *kCICategoryGradient;
extern NSString *kCICategoryStylize;
extern NSString *kCICategorySharpen;
extern NSString *kCICategoryBlur;
extern NSString *kCICategoryVideo;
extern NSString *kCICategoryStillImage;
extern NSString *kCICategoryInterlaced;
extern NSString *kCICategoryNonSquarePixels;
extern NSString *kCICategoryHighDynamicRange ;
extern NSString *kCICategoryBuiltIn;

至于在运行时获取它们,除了枚举它们之外,我没有看到任何其他选项。 这是答案

于 2013-04-04T08:15:34.293 回答