From 52766a03fbb0b4ee5bd6f5abd2cbe5d1d7b8e4d8 Mon Sep 17 00:00:00 2001 From: Mattijs Fuijkschot Date: Mon, 21 May 2018 16:04:54 +0200 Subject: [PATCH] Fixes UI glitch when drawing selective corners with borderRadius MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On devices (not simulator) running iOS 11 there seems to be a bug when drawing selective borders with a corner radius. A "bleeding" line appears on corners that don't have a radius while an adjacent corner has. It’s most likely a bug with iOS 11 itself as the original code is according to spec and it works fine in an iOS 11 simulator. However it turns out that this patch is a workaround for this problem. This patch increases the stretchable area to 2pt instead of 1pt after witch the glitch dissappears. I assume shouldn’t have a negative performance impact as it also enforces resizingMode UIImageResizingModeStretch. --- React/Views/RCTBorderDrawing.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/React/Views/RCTBorderDrawing.m b/React/Views/RCTBorderDrawing.m index 7674f1d154f8ef..8a463b2f0b4d24 100644 --- a/React/Views/RCTBorderDrawing.m +++ b/React/Views/RCTBorderDrawing.m @@ -225,9 +225,9 @@ static CGContextRef RCTUIGraphicsBeginImageContext(CGSize size, CGColorRef backg }; const CGSize size = makeStretchable ? (CGSize){ - // 1pt for the middle stretchable area along each axis - edgeInsets.left + 1 + edgeInsets.right, - edgeInsets.top + 1 + edgeInsets.bottom + // 2pt for the middle stretchable area along each axis + edgeInsets.left + 2 + edgeInsets.right, + edgeInsets.top + 2 + edgeInsets.bottom } : viewSize; CGContextRef ctx = RCTUIGraphicsBeginImageContext(size, backgroundColor, hasCornerRadii, drawToEdge); @@ -385,7 +385,7 @@ static CGContextRef RCTUIGraphicsBeginImageContext(CGSize size, CGColorRef backg UIGraphicsEndImageContext(); if (makeStretchable) { - image = [image resizableImageWithCapInsets:edgeInsets]; + image = [image resizableImageWithCapInsets:edgeInsets resizingMode: UIImageResizingModeStretch]; } return image;