Alpha图像的自定义绘图

时间:2009-09-25 18:01:31

标签: iphone iphone-sdk-3.0 image drawing drawrect

我正在尝试自定义绘制图像(使用alpha)并最终对其应用不同的颜色色调。现在我只是想正确地绘制它。这可能是一个简单的问题,但结果是我的图像上的ALPHA是黑色的。图像是从具有正确alpha的photoshop创建的.png。

- (void) drawRect:(CGRect)area
{

[imgView.image drawInRect: area blendMode:blendMode alpha:alpha]; // draw image
}

blendMode是正常的,alpha是1.0。图像很好,除了alpha是黑色。任何帮助表示赞赏。

尝试了另一种绘图方法,但显示黑色alpha和颠倒(不关心它现在正在上升)

- (void) drawRect:(CGRect)area
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);

// Draw picture first
CGContextDrawImage(context, area, imgView.image.CGImage);

CGContextRestoreGState(context);
}

2 个答案:

答案 0 :(得分:0)

我相信当你使用drawInRect:blendMode:alpha时,你传入的alpha会覆盖你图片中的alpha。我刚才看到的文档不太清楚。

答案 1 :(得分:0)

[imagename drawInRect:CGRectMake(x, y, width, height)];

[imagename drawAtPoint:CGPointMake(x, y)];
相关问题