147 lines
3.4 KiB
Objective-C
Executable File
147 lines
3.4 KiB
Objective-C
Executable File
//
|
||
// JHRefreshAmazingAniView.m
|
||
// JHRefresh
|
||
//
|
||
// Created by Jiahai on 14-9-17.
|
||
// Copyright (c) 2014年 Jiahai. All rights reserved.
|
||
//
|
||
|
||
#import "JHRefreshAmazingAniView.h"
|
||
#import "JHRefreshMacro.h"
|
||
#import "UIView+JHExtension.h"
|
||
|
||
@implementation JHRefreshAmazingAniView
|
||
|
||
- (id)initWithFrame:(CGRect)frame
|
||
{
|
||
self = [super initWithFrame:frame];
|
||
if (self) {
|
||
|
||
// Initialization code
|
||
|
||
_aniImgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:JHRefreshSrcName(@"JHdown_anim__0001.png")]];
|
||
_aniImgView.frame = CGRectMake(0, 0, 50, 50);
|
||
_aniImgView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin;
|
||
[self addSubview:_aniImgView];
|
||
}
|
||
return self;
|
||
}
|
||
|
||
- (void)layoutSubviews
|
||
{
|
||
[super layoutSubviews];
|
||
|
||
_aniImgView.center = CGPointMake(self.jh_width*0.5, self.jh_height*0.5);
|
||
}
|
||
|
||
/*
|
||
// Only override drawRect: if you perform custom drawing.
|
||
// An empty implementation adversely affects performance during animation.
|
||
- (void)drawRect:(CGRect)rect
|
||
{
|
||
// Drawing code
|
||
}
|
||
*/
|
||
|
||
#pragma mark - JHRefreshViewDelegate
|
||
|
||
/**
|
||
* 下拉时的动画
|
||
*/
|
||
- (void)refreshViewAniToBePulling
|
||
{
|
||
|
||
}
|
||
/**
|
||
* 变成普通状态时的动画
|
||
*/
|
||
- (void)refreshViewAniToBeNormal
|
||
{
|
||
[_aniImgView stopAnimating];
|
||
}
|
||
/**
|
||
* 刷新开始
|
||
*/
|
||
- (void)refreshViewBeginRefreshing
|
||
{
|
||
if(!_aniImgView.animationImages)
|
||
{
|
||
// _aniImgView.animationImages = [NSArray arrayWithObjects:
|
||
// [UIImage imageNamed:JHRefreshSrcName(@"dropdown_loading_01.png")],
|
||
// [UIImage imageNamed:JHRefreshSrcName(@"dropdown_loading_02.png")],
|
||
//
|
||
// nil];
|
||
|
||
NSMutableArray *images = [[NSMutableArray alloc] init];
|
||
|
||
for (int i = 1; i <= 63; i ++) {
|
||
|
||
if (i < 10) {
|
||
[images addObject:[UIImage imageNamed:[NSString stringWithFormat:@"neves000%d",i]]];
|
||
|
||
}else{
|
||
[images addObject:[UIImage imageNamed:[NSString stringWithFormat:@"neves00%d",i]]];
|
||
}
|
||
|
||
}
|
||
|
||
_aniImgView.animationImages=images;
|
||
|
||
_aniImgView.animationDuration = 2.0;
|
||
_aniImgView.animationRepeatCount = 0;
|
||
|
||
}
|
||
|
||
//刷新开始时,设置aniImageView的宽高
|
||
_aniImgView.jh_width = _aniImgView.jh_height = JHRefreshViewHeight;
|
||
[_aniImgView startAnimating];
|
||
}
|
||
/**
|
||
* 刷新结束
|
||
*
|
||
* @param result 刷新结果
|
||
*/
|
||
- (void)refreshViewEndRefreshing:(JHRefreshResult)result
|
||
{
|
||
|
||
}
|
||
/**
|
||
* 拖拽到对应的位置
|
||
*
|
||
* @param pos 位置,范围:1 ~ JHRefreshViewHeight
|
||
*/
|
||
- (void)refreshViewPullingToPosition:(NSInteger)pos
|
||
{
|
||
if(pos == 0)
|
||
{
|
||
return;
|
||
}
|
||
CGPoint center = _aniImgView.center;
|
||
|
||
_aniImgView.jh_width = _aniImgView.jh_height = pos;
|
||
|
||
_aniImgView.center = center;
|
||
NSString*name=nil;
|
||
|
||
name =@"neves0063.png";
|
||
//name = [NSString stringWithFormat:@"dropdown_anim__000%d.png",(int)pos];
|
||
|
||
// if (pos<10) {
|
||
// name = [NSString stringWithFormat:@"neves000%d.png",(int)pos];
|
||
// }else{
|
||
// name = [NSString stringWithFormat:@"neves00%d.png",(int)pos];
|
||
// }
|
||
|
||
|
||
|
||
|
||
//NSLog(@"pos%ld",(long)pos);
|
||
|
||
_aniImgView.image = [UIImage imageNamed:name];
|
||
|
||
|
||
}
|
||
|
||
|
||
@end
|