composite colors: CALayer and blend mode on iPhone

I managed to get the affect of compositing multiple CALayers by drawing them directly into a UIView’s graphics context.

-(void)drawRect:(CGRect)rect {
 CGContextRef c = UIGraphicsGetCurrentContext();
 CGContextSetBlendMode(c, kCGBlendModeDifference);
 [myLayer drawInContext:c];
}

BTW, I did not add the layers as sublayers of the view’s layer (that is I never called [myView.layer addSublayer:myLayer])

Leave a Comment