Set the blend mode to CALayer with CIFilters

I am trying to use the backgroundFilters CALayer property to control a kind of Blendmode.

This is my current structure:

LAYER A 
   |
   |_______LAYER B 

      

  • Content Layer A

    is an image.
  • Layer B

    is a sublayer Layer A

    and has a red backgroundColor

What I am trying to do is blend the content Layer A

using backgroundColor Layer B

.

I added the filter B

this way:

    CIFilter *blending = [CIFilter filterWithName:@"CIColorBlendMode"];
    blending.name = @"blendingFilter";

    [blending setDefaults];
    layerB.filters = [NSArray arrayWithObject:blending];

      

But that won't work.

What is the correct way to create a colorBlending effect between two layers?

(I am working on OSX, not iOS)

+3


source to share





All Articles