HJLoadingView.m 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //
  2. // HJLoadingView.m
  3. // HappyJob
  4. //
  5. // Created by Bob on 2019/4/22.
  6. // Copyright © 2019 Bob. All rights reserved.
  7. //
  8. #import "HJLoadingView.h"
  9. #import "UIImageView+FBRotation.h"
  10. @interface HJLoadingView ()
  11. @property (nonatomic, strong) UIImageView *imageView;
  12. @end
  13. @implementation HJLoadingView
  14. - (instancetype)init {
  15. if (self = [super init]) {
  16. self.backgroundColor = [UIColor whiteColor];
  17. [self addSubview:self.imageView];
  18. [self makeConstraints];
  19. // 开始旋转
  20. [self.imageView fb_startAnimation];
  21. }
  22. return self;
  23. }
  24. - (void)makeConstraints {
  25. [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
  26. make.center.equalTo(self);
  27. make.size.mas_equalTo(self.imageView.frame.size);
  28. }];
  29. }
  30. #pragma mark - getters and setters
  31. - (UIImageView *)imageView {
  32. if (_imageView == nil) {
  33. _imageView = [[UIImageView alloc] init];
  34. _imageView.image = [UIImage imageNamed:@"loading_image_white"];
  35. _imageView.contentMode = UIViewContentModeCenter;
  36. _imageView.backgroundColor = [UIColor colorWithRed:81/255.0 green:145/255.0 blue:211/255.0 alpha:1.0];
  37. _imageView.frame = CGRectMake(0, 0, 62, 62);
  38. _imageView.layer.cornerRadius = 31;
  39. _imageView.layer.masksToBounds = YES;
  40. }
  41. return _imageView;
  42. }
  43. @end