title: composite colors: CALayer and blend mode on iPhone
body: <p>I'm trying to use core image on the iphone. I'm able to composite my colors using quartz to draw an uiview, but I want to separate each component into <code>CALayer</code> (UIview consume more resources).</p>
  
  <p>So I have a white mask I want to use to filter a background bitmap, and I want to try different blending mode. Unfortunately, the layers are only "adding" their colors.</p>
  
  <p>Here is my code: </p>
  
  <pre><code>@implementation WhiteLayerHelper
  
      - (void)drawLayer:(CALayer *)theLayer
              inContext:(CGContextRef)myContext
      {
          // draw a white overlay, with special blending and alpha values, so that the saturation can be animated
          CGContextSetBlendMode(myContext,kCGBlendModeSaturation);
          CGContextSetRGBFillColor(myContext,1.0,1.0,1.0,0.9);
          CGContextFillRect(myContext,[UIScreen mainScreen].bounds);
  
      }
  
  @end
  </code></pre>
  
  <p>And here is the main view <code>drawrect</code> code, where I use my CALayer:</p>
  
  <pre><code>- (void)drawRect:(CGRect)rect {
      //get the drawing context
      CGContextRef myContext = UIGraphicsGetCurrentContext();
      // draw the background
      [self fillContext:myContext withBounds:m_overlayRect withImage:m_currentImage];
      [whiteLayer renderInContext:myContext];
  
  }
  </code></pre>
  
  <p>Is there something wrong?</p>