From e183478466b1fa6cfa1ad68aae0390038bc0da51 Mon Sep 17 00:00:00 2001 From: Mikael Sand Date: Sun, 13 Jan 2019 01:25:30 +0200 Subject: [PATCH] [iOS] Fix bounds, center and frame calculation for Image elements. --- ios/Elements/RNSVGImage.m | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ios/Elements/RNSVGImage.m b/ios/Elements/RNSVGImage.m index 638f31d0..1f4c80ba 100644 --- a/ios/Elements/RNSVGImage.m +++ b/ios/Elements/RNSVGImage.m @@ -129,6 +129,18 @@ CGContextConcatCTM(context, viewbox); CGContextDrawImage(context, imageBounds, _image); CGContextRestoreGState(context); + + CGRect bounds = hitArea; + self.clientRect = bounds; + CGAffineTransform transform = CGAffineTransformConcat(self.matrix, self.transforms); + CGPoint mid = CGPointMake(CGRectGetMidX(bounds), CGRectGetMidY(bounds)); + CGPoint center = CGPointApplyAffineTransform(mid, transform); + + self.bounds = bounds; + if (!isnan(center.x) && !isnan(center.y)) { + self.center = center; + } + self.frame = bounds; } - (CGRect)getHitArea