From c69e9e22c1c87b38f464b7d9f33c140a8bf93284 Mon Sep 17 00:00:00 2001 From: Mikael Sand Date: Mon, 7 Oct 2019 21:23:52 +0300 Subject: [PATCH] fix(ios): image viewBox opposite handling of y alignment, fixes #1138 --- ios/Elements/RNSVGImage.m | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ios/Elements/RNSVGImage.m b/ios/Elements/RNSVGImage.m index d294e53f7..aa2f8794d 100644 --- a/ios/Elements/RNSVGImage.m +++ b/ios/Elements/RNSVGImage.m @@ -129,22 +129,22 @@ - (void)renderLayerTo:(CGContextRef)context rect:(CGRect)rect CGAffineTransform viewbox = [RNSVGViewBox getTransform:imageBounds eRect:hitArea align:self.align meetOrSlice:self.meetOrSlice]; [self clip:context]; - CGContextTranslateCTM(context, 0, hitArea.size.height); - CGContextScaleCTM(context, 1, -1); CGContextClipToRect(context, hitArea); CGContextConcatCTM(context, viewbox); + CGContextTranslateCTM(context, 0, imageBounds.size.height); + CGContextScaleCTM(context, 1, -1); CGContextDrawImage(context, imageBounds, _image); CGContextRestoreGState(context); CGRect bounds = hitArea; self.clientRect = bounds; - + CGAffineTransform current = CGContextGetCTM(context); CGAffineTransform svgToClientTransform = CGAffineTransformConcat(current, self.svgView.invInitialCTM); - + self.ctm = svgToClientTransform; self.screenCTM = current; - + CGAffineTransform transform = CGAffineTransformConcat(self.matrix, self.transforms); CGPoint mid = CGPointMake(CGRectGetMidX(bounds), CGRectGetMidY(bounds)); CGPoint center = CGPointApplyAffineTransform(mid, transform); @@ -159,7 +159,7 @@ - (void)renderLayerTo:(CGContextRef)context rect:(CGRect)rect - (CGRect)getHitArea { CGFloat x = [self relativeOnWidth:self.x]; - CGFloat y = -1 * [self relativeOnHeight:self.y]; + CGFloat y = [self relativeOnHeight:self.y]; CGFloat width = [self relativeOnWidth:self.imagewidth]; CGFloat height = [self relativeOnHeight:self.imageheight]; if (width == 0) {