我试图在iPhone上使用的核心形象。 我能够使用石英绘制的UIView的复合我的色彩,但我想每个部件为单独CALayer
(UIView的消耗更多的资源)。
所以我有一个白色口罩我想用它来过滤背景位图,我想尝试不同的混合模式。 不幸的是,该层是唯一的“并称”自己的颜色。
这里是我的代码:
@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
这里是主视图drawrect
代码,其中我用我的CALayer:
- (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];
}
有什么不对?