Skip to content

Commit

Permalink
fix(ios): image viewBox opposite handling of y alignment, fixes #1138
Browse files Browse the repository at this point in the history
  • Loading branch information
msand committed Oct 7, 2019
1 parent fcd66fb commit c69e9e2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ios/Elements/RNSVGImage.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand Down

0 comments on commit c69e9e2

Please sign in to comment.