OliveappEyeLayer.m 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //
  2. // OliveappEyeView.m
  3. // AppSampleYitu
  4. //
  5. // Created by kychen on 17/1/13.
  6. // Copyright © 2017年 Oliveapp. All rights reserved.
  7. //
  8. #import "OliveappEyeLayer.h"
  9. @implementation OliveappEyeLayer
  10. /**
  11. 眼睛动画
  12. @param position <#position description#>
  13. @param delay <#delay description#>
  14. */
  15. - (void)animationAt:(CGPoint)position
  16. withDelay:(CGFloat)delay{
  17. [CATransaction begin];
  18. [CATransaction setDisableActions:YES];
  19. self.opacity = 0;
  20. self.position = position;
  21. [CATransaction commit];
  22. {
  23. CAKeyframeAnimation * animation = [CAKeyframeAnimation animation];
  24. animation.keyPath = @"transform";
  25. animation.values = @[
  26. [NSValue valueWithCATransform3D:CATransform3DIdentity],
  27. [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.35, 0.35, 1)],
  28. [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.6, 0.6, 1)],
  29. [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.3, 0.3, 1)]
  30. ];
  31. animation.duration = 0.5f;
  32. animation.beginTime = CACurrentMediaTime() + delay;
  33. self.transform = CATransform3DMakeScale(0.3, 0.3, 1);
  34. [self addAnimation:animation forKey:nil];
  35. }
  36. {
  37. CABasicAnimation * animation = [CABasicAnimation animationWithKeyPath:@"opacity"];
  38. animation.fromValue = [NSNumber numberWithFloat:0.0f];
  39. animation.toValue = [NSNumber numberWithFloat:1.0f];
  40. animation.duration = 0.5f;
  41. animation.beginTime = CACurrentMediaTime() + delay;
  42. self.opacity = 1.0f;
  43. [self addAnimation:animation forKey:nil];
  44. }
  45. {
  46. CABasicAnimation * animation = [CABasicAnimation animation];
  47. animation.beginTime = CACurrentMediaTime() + 0.65f;
  48. animation.keyPath = @"opacity";
  49. animation.fromValue = @(1.0f);
  50. animation.toValue = @(0.0f);
  51. animation.duration = 0.2f;
  52. animation.beginTime = CACurrentMediaTime() + delay;
  53. self.opacity = 0.0f;
  54. [self addAnimation:animation forKey:nil];
  55. }
  56. }
  57. @end