composite colors: CALayer and blend mode on iPhone

前端 未结 3 740
太阳男子
太阳男子 2020-12-01 10:21

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 CALayer

3条回答
  •  借酒劲吻你
    2020-12-01 10:29

    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])

提交回复
热议问题