From c87248545931ce868dc92dbba353fd2d99b52e60 Mon Sep 17 00:00:00 2001 From: Adlai Holler Date: Thu, 17 Sep 2015 21:59:52 -0700 Subject: [PATCH] Fill image context with background color if image node is opaque --- AsyncDisplayKit/ASImageNode.mm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/AsyncDisplayKit/ASImageNode.mm b/AsyncDisplayKit/ASImageNode.mm index dce8d0f076..11b4ac5f23 100644 --- a/AsyncDisplayKit/ASImageNode.mm +++ b/AsyncDisplayKit/ASImageNode.mm @@ -227,6 +227,12 @@ // Use contentsScale of 1.0 and do the contentsScale handling in boundsSizeInPixels so ASCroppedImageBackingSizeAndDrawRectInBounds // will do its rounding on pixel instead of point boundaries UIGraphicsBeginImageContextWithOptions(backingSize, parameters.opaque, 1.0); + + // if view is opaque, fill the context with background color + if (parameters.opaque && parameters.backgroundColor) { + [parameters.backgroundColor setFill]; + [[UIBezierPath bezierPathWithRect:{ .size = backingSize }] fill]; + } [image drawInRect:imageDrawRect];