fix transparent bug

This commit is contained in:
Horcrux
2016-04-24 12:31:47 +08:00
parent f887fc66ff
commit a0c23868cb

View File

@@ -45,14 +45,15 @@
- (void)renderTo:(CGContextRef)context - (void)renderTo:(CGContextRef)context
{ {
float opacity = self.opacity; float opacity = self.opacity;
BOOL transparent = NO;
if (opacity <= 0) { if (opacity <= 0) {
// Nothing to paint // Nothing to paint
return; return;
} }
if (opacity >= 1) {
BOOL transparent = opacity < 1;
if (!transparent) {
opacity = 1; opacity = 1;
transparent = YES;
} }
// This needs to be painted on a layer before being composited. // This needs to be painted on a layer before being composited.
@@ -61,7 +62,6 @@
CGContextSetAlpha(context, opacity); CGContextSetAlpha(context, opacity);
if (transparent) { if (transparent) {
CGContextBeginTransparencyLayer(context, NULL); CGContextBeginTransparencyLayer(context, NULL);
} }
[self renderLayerTo:context]; [self renderLayerTo:context];
if (transparent) { if (transparent) {