iPhoneでコアイメージを使用しようとしています。私はクオーツを使用して色を合成してUIを描画することができますが、各コンポーネントをCALayer
に分けたい(UIviewはより多くのリソースを消費します)。複合色:iPhoneのCALayerとブレンドモード
私は背景ビットマップをフィルタリングするために使用したい白いマスクがあります。異なるブレンドモードを試してみたいと思います。残念ながら、レイヤーは色を「追加」するだけです。ここで
は私のコードです:
@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
そして、ここでは、私は私のCALayerを使用し、メインビューdrawrect
コード、次のとおりです。
- (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];
}
何か問題はありますか?
CoreImageがiOSで利用できないのですか? – openfrog
@openfrogはい、OS Xと比較して制限されています。たとえば、OS Xの場合、CALayersはcompositing filte rs。 iOS上ではなく、そんなに。 –