CNRefreshHeader.m 1.73 KB
//
//  CNRefreshHeader.m
//  CNLiveRefeshHeader
//
//  Created by 殷巧娟 on 2018/12/8.
//

#import "CNRefreshHeader.h"

#define OffestY -54.0
@interface CNRefreshHeader()

@property (nonatomic ,strong) NSMutableArray *imgMuArr;
@end

@implementation CNRefreshHeader

//初始化
-(void)prepare
{
    [super prepare];
    
    for (int i = 0; i < 30; i ++) {
        [self.imgMuArr addObject:[self getBundleImg:[NSString stringWithFormat:@"activity_load%d",i]]  ];
    }
    [self setImages:self.imgMuArr duration:1 forState:MJRefreshStateIdle];
    [self setImages:self.imgMuArr forState:MJRefreshStatePulling];
    [self setImages:self.imgMuArr forState:MJRefreshStateRefreshing];
    
    self.stateLabel.hidden = YES;
    self.lastUpdatedTimeLabel.hidden = YES;
}

//摆放子控件
- (void)placeSubviews
{
    [super placeSubviews];
    NSLog(@"%@",self.subviews);
    
}

- (NSMutableArray *)imgMuArr
{
    if (!_imgMuArr) {
        _imgMuArr = [NSMutableArray array];
    }
    return _imgMuArr;
}

- (UIImage *)getBundleImg:(NSString *)imgName{
    NSString *path = [[NSBundle mainBundle] pathForResource:@"CNLiveRefeshHeader.framework/CNLiveRefeshHeader" ofType:@"bundle"];
    if (path == nil) {
        NSBundle *bundle = [NSBundle bundleForClass:[self class]];
        NSURL *url = [bundle URLForResource:@"CNLiveRefeshHeader" withExtension:@"bundle"];
        NSBundle *imageBundle = [NSBundle bundleWithURL:url];
        
        NSString *path2 = [imageBundle pathForResource:imgName ofType:@"png"];
        return [UIImage imageWithContentsOfFile:path2];
    }
    NSBundle *imageBundle = [NSBundle bundleWithPath:path];
    NSString *close = [imageBundle pathForResource:imgName ofType:@"png"];
    return  [UIImage imageWithContentsOfFile:close];
}
@end