Guest User

Untitled

a guest
Jan 17th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. - (void)turnUp:(BOOL)aBool {
  2. [UIView beginAnimations:nil context:NULL];
  3. [UIView setAnimationDuration:kFlipAnimationDuration * 0.5];
  4. [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
  5. [UIView setAnimationDelegate:self];
  6. [UIView setAnimationDidStopSelector:@selector(turnHalftime)];
  7. CATransform3D flipTransform = CATransform3DIdentity;
  8. flipTransform.m34 = kFlipPerspective;
  9. flipTransform = CATransform3DRotate(flipTransform, M_PI / 2.0, 0.0f, 1.0f, 0.0f);
  10. flipTransform = CATransform3DTranslate(flipTransform, -kFlipHeight, 0.0f, 0.0f);
  11. flipTransform = CATransform3DScale(flipTransform, kFlipScale, kFlipScale, kFlipScale);
  12. cardView.layer.transform = flipTransform;
  13. [UIView commitAnimations];
  14. }
  15.  
  16. - (void)turnHalftime {
  17. CATransform3D flipTransform = CATransform3DIdentity;
  18. flipTransform.m34 = kFlipPerspective;
  19. flipTransform = CATransform3DRotate(flipTransform,(-M_PI/2.0) - 0.001f, 0.0f, 1.0f, 0.0f);
  20. flipTransform = CATransform3DTranslate(flipTransform, kFlipHeight, 0.0f, 0.0f);
  21. flipTransform = CATransform3DScale(flipTransform, kFlipScale, kFlipScale, kFlipScale);
  22. cardView.layer.transform = flipTransform;
  23.  
  24. [UIView beginAnimations:nil context:NULL];
  25. [UIView setAnimationDuration:kFlipAnimationDuration * 0.5];
  26. [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
  27. [UIView setAnimationDelegate:self];
  28. [UIView setAnimationDidStopSelector:@selector(turnAnimationFinished)];
  29. CATransform3D flipTransform2 = CATransform3DMakeScale(kCardHeight / kCardImageHeight, kCardWidth / kCardImageWidth, 1.0f);
  30. flipTransform2.m34 = kFlipPerspective;
  31. flipTransform2 = CATransform3DRotate(flipTransform2, 0.0, 0.0f, 1.0f, 0.0f);
  32. flipTransform2 = CATransform3DTranslate(flipTransform2, 0.0f, 0.0f, 0.0f);
  33. cardView.layer.transform = flipTransform2;
  34. [UIView commitAnimations];
  35. }
  36.  
  37. #define kFlipAnimationDuration 0.35f
  38. #define kFlipPerspective 1.0f / -600.0f
  39. #define kFlipHeight 90.0f
  40. #define kFlipScale 0.7f
Add Comment
Please, Sign In to add comment