Initial commit

This commit is contained in:
ifish
2017-08-15 16:59:01 +08:00
commit bdc83e07ef
5766 changed files with 423223 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
//
// JHRefreshAmazingAniView.h
// JHRefresh
//
// Created by Jiahai on 14-9-17.
// Copyright (c) 2014年 Jiahai. All rights reserved.
//
#import "JHRefreshAniBaseView.h"
@interface JHRefreshAmazingAniView : JHRefreshAniBaseView
{
UIImageView *_aniImgView;
}
@end
+146
View File
@@ -0,0 +1,146 @@
//
// 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
+17
View File
@@ -0,0 +1,17 @@
//
// JHRefreshAniBaseView.h
// JHRefresh
//
// Created by Jiahai on 14-9-15.
// Copyright (c) 2014年 Jiahai. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "JHRefreshViewDelegate.h"
#import "JHRefreshConfig.h"
@interface JHRefreshAniBaseView : UIView<JHRefreshViewDelegate>
@property (nonatomic, assign) JHRefreshViewType refreshViewType;
@property (nonatomic, assign) NSInteger refreshViewID;
@end
+74
View File
@@ -0,0 +1,74 @@
//
// JHRefreshAniBaseView.m
// JHRefresh
//
// Created by Jiahai on 14-9-15.
// Copyright (c) 2014年 Jiahai. All rights reserved.
//
#import "JHRefreshAniBaseView.h"
#import "JHRefreshHeaderView.h"
#import "JHRefreshFooterView.h"
#import "UIView+JHExtension.h"
@implementation JHRefreshAniBaseView
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
self.autoresizingMask = UIViewAutoresizingFlexibleWidth;
}
return self;
}
- (void)willMoveToSuperview:(UIView *)newSuperview
{
[super willMoveToSuperview:newSuperview];
self.jh_width = newSuperview.jh_width;
self.jh_height = newSuperview.jh_height;
if([newSuperview isKindOfClass:[JHRefreshHeaderView class]])
{
self.refreshViewType = JHRefreshViewTypeHeader;
}
else if([newSuperview isKindOfClass:[JHRefreshFooterView class]])
{
self.refreshViewType = JHRefreshViewTypeFooter;
}
self.refreshViewID = ((JHRefreshBaseView *)newSuperview).ID;
}
#pragma mark - JHRefreshViewDelegate
- (void)refreshViewAniToBePulling
{
}
- (void)refreshViewAniToBeNormal
{
}
- (void)refreshViewBeginRefreshing
{
}
- (void)refreshViewEndRefreshing:(JHRefreshResult)result
{
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
}
*/
@end
+21
View File
@@ -0,0 +1,21 @@
//
// JHRefreshCommonAniView.h
// JHRefresh
//
// Created by Jiahai on 14-9-15.
// Copyright (c) 2014年 Jiahai. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "JHRefreshMacro.h"
#import "JHRefreshAniBaseView.h"
@interface JHRefreshCommonAniView : JHRefreshAniBaseView
{
UIImageView *_arrowImgView;
UIImageView* _leftImgView;
UIActivityIndicatorView *_activityView;
UILabel *_statusLabel;
UILabel *_lastUpdateTimeLabel;
}
@end
+211
View File
@@ -0,0 +1,211 @@
//
// JHRefreshCommonAniView.m
// JHRefresh
//
// Created by Jiahai on 14-9-15.
// Copyright (c) 2014年 Jiahai. All rights reserved.
//
#import "JHRefreshCommonAniView.h"
#import "UIView+JHExtension.h"
#import "JHRefreshConfig.h"
#define ROT 3.14159265358979323846264338327950288
#define JHRefreshLabelTextColor JHRGBA(150,150,150,1)
@implementation JHRefreshCommonAniView
NSString *const JHRefreshHeaderStatusTextNormal = @"下拉刷新";
NSString *const JHRefreshHeaderStatusTextPulling = @"松开既可刷新";
NSString *const JHRefreshHeaderStatusTextRefreshing = @"正在刷新。。。";
NSString *const JHRefreshHeaderStatusTextSuccess = @"刷新成功";
NSString *const JHRefreshHeaderStatusTextFailure = @"刷新失败";
NSString *const JHRefreshFooterStatusTextNormal = @"上拉加载更多";
NSString *const JHRefreshFooterStatusTextPulling = @"松开既可加载";
NSString *const JHRefreshFooterStatusTextRefreshing = @"正在加载。。。";
NSString *const JHRefreshFooterStatusTextSuccess = @"加载成功";
NSString *const JHRefreshFooterStatusTextFailure = @"加载失败";
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
_statusLabel = [[UILabel alloc] init];
_statusLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
_statusLabel.font = [UIFont boldSystemFontOfSize:13];
_statusLabel.textColor = JHRefreshLabelTextColor;
_statusLabel.backgroundColor = [UIColor clearColor];
_statusLabel.textAlignment = NSTextAlignmentCenter;
[self addSubview:_statusLabel];
_statusLabel.text = JHRefreshHeaderStatusTextNormal;
_lastUpdateTimeLabel = [[UILabel alloc] init];
_lastUpdateTimeLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
_lastUpdateTimeLabel.font = [UIFont boldSystemFontOfSize:13];
_lastUpdateTimeLabel.textColor = JHRefreshLabelTextColor;
_lastUpdateTimeLabel.backgroundColor = [UIColor clearColor];
_lastUpdateTimeLabel.textAlignment = NSTextAlignmentCenter;
[self addSubview:_lastUpdateTimeLabel];
_lastUpdateTimeLabel.text = [JHRefreshConfig getLastUpdateTimeWithRefreshViewID:self.refreshViewID];
// _arrowImgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:JHRefreshSrcName(@"dropdown_loading_01")]];
_arrowImgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@""]];
_arrowImgView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin;
[self addSubview:_arrowImgView];
// _leftImgView=[[UIImageView alloc]initWithImage:[UIImage imageNamed:JHRefreshSrcName(@"dropdown_loading_01")]];
// _leftImgView.bounds=_arrowImgView.bounds;
// _leftImgView.autoresizingMask=_arrowImgView.autoresizingMask;
// [self addSubview:_leftImgView];
_activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
_activityView.bounds = _arrowImgView.bounds;
_activityView.autoresizingMask = _arrowImgView.autoresizingMask;
[self addSubview:_activityView];
}
return self;
}
- (void)willMoveToSuperview:(UIView *)newSuperview
{
[super willMoveToSuperview:newSuperview];
if(self.refreshViewType == JHRefreshViewTypeFooter)
{
_statusLabel.text = JHRefreshFooterStatusTextNormal;
_arrowImgView.transform = CGAffineTransformMakeRotation(M_PI);
_lastUpdateTimeLabel.hidden = YES;
}
}
- (void)layoutSubviews
{
[super layoutSubviews];
// 状态
_statusLabel.frame = CGRectMake(0, 0, self.jh_width, self.jh_height*0.5);
// 时间
_lastUpdateTimeLabel.frame = CGRectMake(0, _statusLabel.jh_height, _statusLabel.jh_width, _statusLabel.jh_height);
_arrowImgView.center = CGPointMake(self.jh_width*0.5 - 100, self.jh_height*0.5);
_activityView.center = _arrowImgView.center;
}
#pragma mark - JHRefreshViewDelegate
- (void)refreshViewAniToBePulling
{
switch (self.refreshViewType) {
case JHRefreshViewTypeHeader:
{
_statusLabel.text = JHRefreshHeaderStatusTextPulling;
[UIView animateWithDuration:JHRefreshFastAnimationDuration animations:^{
_arrowImgView.transform = CGAffineTransformMakeRotation(M_PI);
}];
}
break;
case JHRefreshViewTypeFooter:
{
_statusLabel.text = JHRefreshFooterStatusTextPulling;
[UIView animateWithDuration:JHRefreshFastAnimationDuration animations:^{
_arrowImgView.transform = CGAffineTransformIdentity;
}];
}
break;
}
}
- (void)refreshViewAniToBeNormal
{
switch (self.refreshViewType) {
case JHRefreshViewTypeHeader:
{
_statusLabel.text = JHRefreshHeaderStatusTextNormal;
[UIView animateWithDuration:JHRefreshFastAnimationDuration animations:^{
_arrowImgView.transform = CGAffineTransformIdentity;
}];
}
break;
case JHRefreshViewTypeFooter:
{
_statusLabel.text = JHRefreshFooterStatusTextNormal;
[UIView animateWithDuration:JHRefreshFastAnimationDuration animations:^{
_arrowImgView.transform = CGAffineTransformMakeRotation(2*ROT);
}];
}
break;
}
}
- (void)refreshViewBeginRefreshing
{
switch (self.refreshViewType) {
case JHRefreshViewTypeHeader:
{
_statusLabel.text = JHRefreshHeaderStatusTextRefreshing;
}
break;
case JHRefreshViewTypeFooter:
{
_statusLabel.text = JHRefreshFooterStatusTextRefreshing;
}
break;
}
_arrowImgView.hidden = YES;
[_activityView startAnimating];
}
- (void)refreshViewEndRefreshing:(JHRefreshResult)result
{
switch (self.refreshViewType) {
case JHRefreshViewTypeHeader:
{
switch (result) {
case JHRefreshResultNone:
_statusLabel.text = JHRefreshHeaderStatusTextNormal;
break;
case JHRefreshResultSuccess:
{
_statusLabel.text = JHRefreshHeaderStatusTextSuccess;
}
break;
case JHRefreshResultFailure:
{
_statusLabel.text = JHRefreshHeaderStatusTextFailure;
}
break;
}
_arrowImgView.transform = CGAffineTransformIdentity;
}
break;
case JHRefreshViewTypeFooter:
{
_statusLabel.text = JHRefreshHeaderStatusTextNormal;
_arrowImgView.transform = CGAffineTransformMakeRotation(M_PI);
}
break;
}
_lastUpdateTimeLabel.text = [JHRefreshConfig getLastUpdateTimeWithRefreshViewID:self.refreshViewID];
[JHRefreshConfig updateLastUpdateTimeWithRefreshViewID:self.refreshViewID];
[_activityView stopAnimating];
_arrowImgView.hidden = NO;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
}
*/
@end