CIFilterBuiltins
Browsing the Core Image headers, I did find functions for these filters where you could just call
let filter = CIFilter.colorPosterize()Yet every time I tried, it never worked and would give me an error that
CIFilter has no member 'colorPosterize'. Well, “Crap!”, I thought, this must be something that will become available eventually.How wrong I was. This has been available for a while, you just need to know how to do it! The “trick” is to not only
import CoreImage, but also (why!?)import CoreImage.CIFilterBuiltins.
The type-safe approach returns a non-optional filter. Because the returned filter conforms to the relevant protocol—for example,
CIFalseColorin the case offalseColor()—the parameters are available as properties.