我正在尝试在 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];
}
有什么不对?