2
爲什麼obj2不與obj1混合,但不使用CGLayer它工作正常,與CGContextDrawLayerAtPoint相同的問題,CGLayer不支持CGContextSetBlendMode?CGLayers爲什麼不混合?
//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);
非常感謝,我解決了這個問題。 –