CIFilter on iPhone? Nope.

If you look in CALayer.h in the iPhone SDK, you’ll see these properties:

/* An array of filters that will be applied to the contents of the
 * layer and its sublayers. Defaults to nil. Animatable. */

@property(copy) NSArray *filters;

/* An array of filters that are applied to the background of the layer.
 * The root layer ignores this property. Animatable. */

@property(copy) NSArray *backgroundFilters;

While the reference manual is (sort of) clear that the CIFilter class is unavailable:

filters

An array of CoreImage filters that are applied to the contents of the receiver and its sublayers. Animatable.

Special Considerations

While the CALayer class exposes this property, Core Image is not available in iPhone OS. Currently the filters available for this property are undefined.

It gets confusing because their example code (in the iPhone doc set) uses a CIFilter:

// The selection layer will pulse continuously.
// This is accomplished by setting a bloom filter on the layer
 
// create the filter and set its default values
CIFilter *filter = [CIFilter filterWithName:@"CIBloom"];
[filter setDefaults];
[filter setValue:[NSNumber numberWithFloat:5.0] forKey:@"inputRadius"];
 
// name the filter so we can use the keypath to animate the inputIntensity
// attribute of the filter
[filter setName:@"pulseFilter"];
 
// set the filter to the selection layer's filters
[selectionLayer setFilters:[NSArray arrayWithObject:filter]];

But before you get your hopes up, don’t bother trying this. It won’t compile…


Related Posts

  1. iPhone/iPad UISearchBar and UISearchDisplayController Asynchronous Example
  2. SPF Records with Rails and ActionMailer
  3. My 5 Must-have vim Plugins
  4. Rails Fragment Caching With Multiple Accounts
  5. Max OS X Animated GIF Editor Champion -- Pixen
You should follow me on Twitter: @patrickxb