【发布时间】:2012-05-02 11:13:20
【问题描述】:
为什么 obj2 不与 obj1 混合,但不使用 CGLayer 可以正常工作,与 CGContextDrawLayerAtPoint 相同的问题,CGLayer 不支持 CGContextSetBlendMode 吗??
//Layer
CGContextRef context = UIGraphicsGetCurrentContext();
CGLayerRef objectLayer = CGLayerCreateWithContext (context, rect.size, NULL);
CGContextRef objectContext = CGLayerGetContext (objectLayer);
//obj1
CGContextDrawImage(objectContext, CGRectMake(0, 0, rect.size.width, rect.size.height), [[UIImage imageNamed:@"background.png"] CGImage]);
//obj2
CGContextSetBlendMode(objectContext, kCGBlendModeSoftLight);
CGContextSetAlpha(objectContext, 0.5f);
CGContextDrawImage(objectContext, CGRectMake(0, 0, rect.size.width, rect.size.height), [[UIImage imageNamed:@"overlay1.png"] CGImage]);
CGContextDrawLayerInRect(context, rect, objectLayer);
【问题讨论】:
标签: objective-c cocoa-touch drawrect cgcontext cglayer