Skip to content
This repository was archived by the owner on Nov 11, 2024. It is now read-only.

Commit 8cce18b

Browse files
committed
fix: use capInsets for stretchable border image
1 parent 49144ed commit 8cce18b

File tree

1 file changed

+6
-25
lines changed

1 file changed

+6
-25
lines changed

React/Views/RCTBorderDrawing.m

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,11 @@ static CGContextRef RCTUIGraphicsBeginImageContext(CGSize size, CGColorRef backg
240240
borderInsets.right + MAX(cornerInsets.bottomRight.width, cornerInsets.topRight.width)
241241
};
242242

243-
const CGSize size = viewSize;
244-
// makeStretchable ? (CGSize){
245-
// // 1pt for the middle stretchable area along each axis
246-
// edgeInsets.left + 1 + edgeInsets.right,
247-
// edgeInsets.top + 1 + edgeInsets.bottom
248-
// } : viewSize;
243+
const CGSize size = makeStretchable ? (CGSize){
244+
// 1pt for the middle stretchable area along each axis
245+
edgeInsets.left + 1 + edgeInsets.right,
246+
edgeInsets.top + 1 + edgeInsets.bottom
247+
} : viewSize;
249248

250249
CGContextRef ctx = RCTUIGraphicsBeginImageContext(size, backgroundColor, hasCornerRadii, drawToEdge);
251250
const CGRect rect = {.size = size};
@@ -403,25 +402,7 @@ static CGContextRef RCTUIGraphicsBeginImageContext(CGSize size, CGColorRef backg
403402
UIGraphicsEndImageContext();
404403

405404
if (makeStretchable) {
406-
/*
407-
* Strechable solid borders is not implemented
408-
* image = [image resizableImageWithCapInsets:edgeInsets];
409-
**/
410-
411-
// NSInteger left = edgeInsets.left;
412-
// NSInteger top = edgeInsets.top;
413-
// NSImage *strechableImage = [[NSImage alloc] initWithSize:viewSize];
414-
// [strechableImage lockFocus];
415-
// NSSize imgSize = viewSize;
416-
//
417-
//
418-
// [image drawAtPoint:NSMakePoint(0, 0) fromRect:NSMakeRect(0, 0, left, top) operation:NSCompositeSourceOver fraction:1];
419-
// [image drawInRect:NSMakeRect(left, 0, imgSize.width-2*left, top) fromRect:NSMakeRect(left, 0, imgSize.width-2*left, top) operation:NSCompositeSourceOver fraction:1];
420-
// [image drawAtPoint:NSMakePoint(0 + imgSize.width - left, 0) fromRect:NSMakeRect(imgSize.width-left, 0, left, top) operation:NSCompositeSourceOver fraction:1];
421-
// [strechableImage unlockFocus];
422-
//
423-
// image = strechableImage;
424-
405+
image.capInsets = edgeInsets;
425406
}
426407

427408
return image;

0 commit comments

Comments
 (0)