From iPhone Development Wiki
Revision as of 22:24, 21 January 2011 by KennyTM~ (talk | contribs) (Builtin static filters: Added 5 more known filters. Detail to be filled.)
Jump to: navigation, search

CAFilter is an Objective-C wrapper for creating static or transition image filters.

Applying filters to layers

Although the SDK says that the filters property is unused, you can actually apply filter effects with it, for example, to apply a Gaussian blur filter for a window:

CAFilter* filter = [CAFilter filterWithName:@"gaussianBlur"];
[filter setValue:[NSNumber numberWithFloat:5] forKey:@"inputRadius"];
window.layer.filters = [NSArray arrayWithObject:filter];

Builtin static filters

Layers with filters applied, in order: (1) no filter; (2) gaussianBlur; (3) multiplyColor; (4) pageCurl


This will multiply an inputColor to the layer.






The gaussianBlur filter can apply a Gaussian blur effect to the layer. It accepts a float parameter, inputRadius, which specifies the strength of blurring.



The pageCurl filter gives the layer a page curl effect. It accepts 3 float parameters:

  • inputTime (from 0 to 1).
  • inputAngle (in radian, must not be a multiple of π/2).
  • inputRadius (in pixel, the radius of the curled part).

Transition filters

Transition filters also uses CAFilter as the interface, as CATransition also has a filter property. But the transition filters cannot be treated as static filters and applied to layers directly.