JXWaitView.m 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //
  2. // JXWaitView.m
  3. // shiku_im
  4. //
  5. // Created by flyeagleTang on 17/1/13.
  6. // Copyright © 2017年 Reese. All rights reserved.
  7. //
  8. #import "JXWaitView.h"
  9. @implementation JXWaitView
  10. -(id)initWithParent:(UIView*)value{
  11. self = [super init];
  12. if(self){
  13. if(value != nil)
  14. _parent = value;
  15. else
  16. _parent = [UIApplication sharedApplication].keyWindow;
  17. self.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray;
  18. [self adjust];
  19. // [_parent addSubview:self];
  20. }
  21. return self;
  22. }
  23. -(void)dealloc{
  24. // [super dealloc];
  25. }
  26. -(void)start{
  27. [self startAnimating];
  28. self.hidden = NO;
  29. }
  30. -(void)stop{
  31. [self stopAnimating];
  32. self.hidden = YES;
  33. }
  34. -(void)adjust{
  35. if(_parent==nil)
  36. return;
  37. [_parent addSubview:self];
  38. self.center = CGPointMake(_parent.frame.size.width/2, _parent.frame.size.height/2);
  39. }
  40. -(void)setParent:(UIView *)value{
  41. [self adjust];
  42. if([_parent isEqual:value])
  43. return;
  44. // [_parent release];
  45. // _parent = [value retain];
  46. _parent = value;
  47. [self adjust];
  48. }
  49. @end