123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- //
- // FKLoadingView.m
- // FirstLink
- //
- // Created by ascii on 2016/10/25.
- // Copyright © 2016年 FirstLink. All rights reserved.
- //
- #import "FKLoadingView.h"
- @interface FKLoadingView ()
- @property (nonatomic, strong) UIImageView *bgImageView;
- @property (nonatomic, strong) UIImageView *loadingIcon;
- @end
- @implementation FKLoadingView
- /*
- // Only override drawRect: if you perform custom drawing.
- // An empty implementation adversely affects performance during animation.
- - (void)drawRect:(CGRect)rect {
- // Drawing code
- }
- */
- - (instancetype)init {
- self = [super init];
- if (self) {
- self.backgroundColor = [UIColor clearColor];
-
- [self addAllSubviews];
- }
- return self;
- }
- #pragma mark - Method
- - (void)startAnimation {
- CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
- animation.byValue = @(M_PI * 2);
- animation.duration = 0.7f;
- animation.repeatCount = INFINITY;
-
- [self.loadingIcon.layer removeAllAnimations];
- [self.loadingIcon.layer addAnimation:animation forKey:@"sd"];
- }
- #pragma mark - Layout
- - (void)addAllSubviews {
- [self addSubview:self.bgImageView];
- [self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(self);
- make.centerY.equalTo(self).offset(-8);
- make.size.mas_equalTo(CGSizeMake(60, 60));
- }];
-
- [self.bgImageView addSubview:self.loadingIcon];
- [self.loadingIcon mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(self.bgImageView);
- make.centerY.equalTo(self.bgImageView).offset(-2);
- make.size.mas_equalTo(CGSizeMake(24, 24));
- }];
- }
- #pragma mark - Property
- - (UIImageView *)bgImageView {
- if (!_bgImageView) {
- _bgImageView = [UIImageView new];
- _bgImageView.image = [UIImage imageNamed:@"CustomLoadingBgIcon"];
- }
- return _bgImageView;
- }
- - (UIImageView *)loadingIcon {
- if (!_loadingIcon) {
- _loadingIcon = [UIImageView new];
- _loadingIcon.image = [UIImage imageNamed:@"CustomLoadingIcon"];
- }
- return _loadingIcon;
- }
- @end
|