react-native-navigation的迁移库

TransformRectTransition.m 871B

12345678910111213141516171819202122
  1. #import "TransformRectTransition.h"
  2. @implementation TransformRectTransition
  3. - (CATransform3D)animateWithProgress:(CGFloat)p {
  4. CGRect toFrame = [RNNInterpolator fromRect:self.from toRect:self.to precent:p interpolation:self.interpolation];
  5. CGFloat scaleX = toFrame.size.width / self.from.size.width;
  6. CGFloat scaleY = toFrame.size.height / self.from.size.height;
  7. CGFloat offsetX = toFrame.origin.x - self.from.origin.x;
  8. CGFloat offsetY = toFrame.origin.y - self.from.origin.y;
  9. CGFloat translateX = (offsetX + (toFrame.size.width - self.from.size.width)/2);
  10. CGFloat translateY = (offsetY + (toFrame.size.height - self.from.size.height)/2);
  11. CATransform3D translate = CATransform3DMakeTranslation(translateX, translateY, 0);
  12. CATransform3D scale = CATransform3DScale(translate, scaleX, scaleY, 0);
  13. return scale;
  14. }
  15. @end