MyRadarView.m 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //
  2. // MyRadarView.m
  3. // XMEye
  4. //
  5. // Created by Megatron on 4/2/15.
  6. // Copyright (c) 2015 Megatron. All rights reserved.
  7. //
  8. #import "MyRadarView.h"
  9. @implementation MyRadarView
  10. @synthesize angle = _angle;
  11. -(id)initWithFrame:(CGRect)frame
  12. {
  13. self = [super initWithFrame:frame];
  14. if (self) {
  15. int w = frame.size.width; // 背景图的宽高
  16. int h = frame.size.height;
  17. self.bgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"radar_search_bg.png"]];
  18. self.bgView.frame = CGRectMake(0, 0, w, w);
  19. self.bgView.center = CGPointMake(w * 0.5, h * 0.5);
  20. self.bgView.userInteractionEnabled = YES;
  21. [self addSubview:self.bgView];
  22. self.scanSign = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"radar_search_sign.png"]];
  23. self.scanSign.frame = CGRectMake(0, 0, w, w);
  24. self.scanSign.center = CGPointMake(w * 0.5, h *0.5);
  25. self.scanSign.userInteractionEnabled = YES;
  26. self.scanSign.hidden = YES;
  27. [self addSubview:self.scanSign];
  28. }
  29. return self;
  30. }
  31. -(void)startSeek
  32. {
  33. self.scanSign.hidden = NO;
  34. CABasicAnimation* rotationAnimation;
  35. rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
  36. rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 ];
  37. rotationAnimation.duration = 2;
  38. rotationAnimation.cumulative = YES;
  39. rotationAnimation.repeatCount = 9999999;
  40. [self.scanSign.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
  41. }
  42. -(void)stopSeek
  43. {
  44. self.hidden = YES;
  45. }
  46. @end