Skip to content

Commit c69e9e2

Browse files
committed
fix(ios): image viewBox opposite handling of y alignment, fixes #1138
1 parent fcd66fb commit c69e9e2

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

ios/Elements/RNSVGImage.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,22 +129,22 @@ - (void)renderLayerTo:(CGContextRef)context rect:(CGRect)rect
129129
CGAffineTransform viewbox = [RNSVGViewBox getTransform:imageBounds eRect:hitArea align:self.align meetOrSlice:self.meetOrSlice];
130130

131131
[self clip:context];
132-
CGContextTranslateCTM(context, 0, hitArea.size.height);
133-
CGContextScaleCTM(context, 1, -1);
134132
CGContextClipToRect(context, hitArea);
135133
CGContextConcatCTM(context, viewbox);
134+
CGContextTranslateCTM(context, 0, imageBounds.size.height);
135+
CGContextScaleCTM(context, 1, -1);
136136
CGContextDrawImage(context, imageBounds, _image);
137137
CGContextRestoreGState(context);
138138

139139
CGRect bounds = hitArea;
140140
self.clientRect = bounds;
141-
141+
142142
CGAffineTransform current = CGContextGetCTM(context);
143143
CGAffineTransform svgToClientTransform = CGAffineTransformConcat(current, self.svgView.invInitialCTM);
144-
144+
145145
self.ctm = svgToClientTransform;
146146
self.screenCTM = current;
147-
147+
148148
CGAffineTransform transform = CGAffineTransformConcat(self.matrix, self.transforms);
149149
CGPoint mid = CGPointMake(CGRectGetMidX(bounds), CGRectGetMidY(bounds));
150150
CGPoint center = CGPointApplyAffineTransform(mid, transform);
@@ -159,7 +159,7 @@ - (void)renderLayerTo:(CGContextRef)context rect:(CGRect)rect
159159
- (CGRect)getHitArea
160160
{
161161
CGFloat x = [self relativeOnWidth:self.x];
162-
CGFloat y = -1 * [self relativeOnHeight:self.y];
162+
CGFloat y = [self relativeOnHeight:self.y];
163163
CGFloat width = [self relativeOnWidth:self.imagewidth];
164164
CGFloat height = [self relativeOnHeight:self.imageheight];
165165
if (width == 0) {

0 commit comments

Comments
 (0)