How to render CALayer with a different blending mode, such as a screen or multiplication?

I have a UIImageView and want it to display in a specific blend mode. I know that iPhone has different blending modes, and maybe this can be done with a lot of CG code ... but maybe there is a good way with CALayer UIImageView?

+6
iphone
source share
2 answers

see here: composite colors: CALayer and blend mode on iPhone

+1
source share

Set the compositingFilter layer of the view layer to a supported blending mode line. In documents, the compositingFilter layer

The CoreImage filter used to lay out the layer and the content behind it.

For a list of Core Image filters, print the filter names defined by kCICategoryCompositeOperation

[CIFilter filterNamesInCategory:kCICategoryCompositeOperation] 

or directly as

 [CIFilter filterNamesInCategory:@"CICategoryCompositeOperation"] 

The array will include main image filters in the form

 { CIColorBlendMode, CIColorBurnBlendMode, CIColorDodgeBlendMode, CIMultiplyBlendMode, ... } 

To use CIMultiplyBlendMode, set "multiplyBlendMode" as a composite filter at level

 self.layer.compositingFilter = @"multiplyBlendMode"; 
+1
source share

All Articles