[iOS] Fix bounds, center and frame calculation for Use elements.

This commit is contained in:
Mikael Sand
2019-01-13 01:06:20 +02:00
parent f32d144d7a
commit 57b4b56ef6
+11 -2
View File
@@ -68,8 +68,17 @@
// TODO: calling yellow box here // TODO: calling yellow box here
RCTLogWarn(@"`Use` element expected a pre-defined svg template as `href` prop, template named: %@ is not defined.", self.href); RCTLogWarn(@"`Use` element expected a pre-defined svg template as `href` prop, template named: %@ is not defined.", self.href);
} }
self.clientRect = template.clientRect; CGRect bounds = template.clientRect;
self.bounds = template.clientRect; 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;
} }
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {