//
//  CJLoadingView.m
//  FeiPaiCustomer
//
//  Created by newuser on 2017/9/26.
//  Copyright © 2017年 cj. All rights reserved.
//

#import "CJLoadingView.h"
#import "UIViewExt.h"

@interface CJLoadingView()
@property (nonatomic, strong)UIImageView* loadingImageView;
@end

@implementation CJLoadingView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self uiConfig];
    }
    return self;
}
-(void)uiConfig{
//    self.loadingImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 8, 5.5)];
    self.loadingImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 21.5, 14)];

    self.loadingImageView.center = CGPointMake(self.width/2, self.height/2 - 10);
    [self addSubview:self.loadingImageView];
    
    
    NSMutableArray *imgArray = [NSMutableArray array];
    for (int i=1; i<=8; i++) {
//        UIImage *image = KImageNamed([NSString stringWithFormat:@"loading_%i",i]);
//        [imgArray addObject:image];
    }
    self.loadingImageView.animationImages = imgArray;
    self.loadingImageView.animationDuration = 0.8;
    self.loadingImageView.animationRepeatCount = MAXFLOAT;
    
}

-(void)startAnimation{
    self.loadingImageView.center = CGPointMake(self.width/2, self.height/2 - 10);
    [self.loadingImageView startAnimating];

}

-(void)stopAnimation{
    [self.loadingImageView stopAnimating];

}


@end
