Skip to content

Commit 9e65223

Browse files
jamesreggiofacebook-github-bot
authored andcommitted
Fix artifacting on RN-drawn borders with asymmetric radii (#21208)
Summary: This PR fixes an obscure rendering bug on iOS for borders with asymmetric radii. It appears to be a problem with the custom drawing that React Native performs when it cannot use native UIKit/CoreAnimation border drawing. Pull Request resolved: #21208 Differential Revision: D10130120 Pulled By: hramos fbshipit-source-id: d9fbc5c622c060db15658d038a068216b47bb26d
1 parent b6b0fc1 commit 9e65223

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

React/Views/RCTBorderDrawing.m

+9-1
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,21 @@ static CGContextRef RCTUIGraphicsBeginImageContext(CGSize size, CGColorRef backg
217217
(borderInsets.top + cornerInsets.topRight.height +
218218
borderInsets.bottom + cornerInsets.bottomLeft.height <= viewSize.height);
219219

220-
const UIEdgeInsets edgeInsets = (UIEdgeInsets){
220+
UIEdgeInsets edgeInsets = (UIEdgeInsets){
221221
borderInsets.top + MAX(cornerInsets.topLeft.height, cornerInsets.topRight.height),
222222
borderInsets.left + MAX(cornerInsets.topLeft.width, cornerInsets.bottomLeft.width),
223223
borderInsets.bottom + MAX(cornerInsets.bottomLeft.height, cornerInsets.bottomRight.height),
224224
borderInsets.right + MAX(cornerInsets.bottomRight.width, cornerInsets.topRight.width)
225225
};
226226

227+
// Asymmetrical edgeInsets cause strange artifacting on iOS 10 and earlier.
228+
edgeInsets = (UIEdgeInsets){
229+
MAX(edgeInsets.top, edgeInsets.bottom),
230+
MAX(edgeInsets.left, edgeInsets.right),
231+
MAX(edgeInsets.top, edgeInsets.bottom),
232+
MAX(edgeInsets.left, edgeInsets.right),
233+
};
234+
227235
const CGSize size = makeStretchable ? (CGSize){
228236
// 1pt for the middle stretchable area along each axis
229237
edgeInsets.left + 1 + edgeInsets.right,

0 commit comments

Comments
 (0)