OliveappYellowFrame.m 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //
  2. // OliveappYellowFrame.m
  3. // AppSampleYitu
  4. //
  5. // Created by kychen on 17/1/16.
  6. // Copyright © 2017年 Oliveapp. All rights reserved.
  7. //
  8. #import "OliveappYellowFrame.h"
  9. @implementation OliveappYellowFrame
  10. - (void)flashAnimationWithTranslate:(CGFloat)XBias
  11. withDuration:(CGFloat)duration {
  12. CATransform3D transform1 = self.layer.transform;
  13. CATransform3D transform2 = CATransform3DTranslate(transform1, XBias, 0, 0);
  14. CAKeyframeAnimation * animation = [CAKeyframeAnimation animation];
  15. animation.keyPath = @"transform";
  16. animation.values = @[
  17. [NSValue valueWithCATransform3D:transform1],
  18. [NSValue valueWithCATransform3D:transform2],
  19. [NSValue valueWithCATransform3D:transform1]
  20. ];
  21. animation.duration = duration;
  22. animation.timingFunction = [[CAMediaTimingFunction alloc] initWithControlPoints:0.4f :0.0f :0.2f :0.1f];
  23. [self.layer addAnimation:animation forKey:nil];
  24. }
  25. - (void) animationWithTranslate:(CGFloat)XBias
  26. withDuration:(CGFloat)duration
  27. withDelay:(CGFloat)delay {
  28. CATransform3D transform1 = self.layer.transform;
  29. CATransform3D transform2 = CATransform3DTranslate(transform1, XBias, 0, 0);
  30. self.layer.transform = transform2;
  31. CABasicAnimation * animation = [CABasicAnimation animation];
  32. animation.fromValue = [NSValue valueWithCATransform3D:transform1];
  33. animation.keyPath = @"transform";
  34. animation.toValue = [NSValue valueWithCATransform3D:transform2];
  35. animation.beginTime = CACurrentMediaTime() + delay;
  36. animation.duration = duration;
  37. animation.timingFunction = [[CAMediaTimingFunction alloc] initWithControlPoints:0.0f :0.0f :0.2f :1.0f];
  38. [self.layer addAnimation:animation forKey:nil];
  39. }
  40. @end