A lovely refreshing style looks like UIRefreshControl
. It looks like the Slime so I named it SlimeRefresh.
Screenshot:
1,down the source from https://github.com/dbsGen/SlimeRefresh/
- git :
git clone https://github.com/dbsGen/SlimeRefresh.git SlimeRefresh
2,add all under SlimeRefresh/SlimeRefresh to your project.
3,#import "SRRefreshView.h"
4,init SRRefreshView and add it to a UIScrollView.
just like:
_slimeView = [[SRRefreshView alloc] init];
_slimeView.delegate = self;
[_tableView addSubview:_slimeView];
A protocol and a block, choise one.
- (void)slimeRefreshStartRefresh:(SRRefreshView*)refreshView;
Only one protocol, you have to implement. it will be called when the refreshing will be executed.
and here is the other way:
@property (nonatomic, copy) SRRefreshBlock block;
as you see there is a block to receive the refresh event.just like:
__block __unsafe_unretained id this = self;
[refreshView setBlock:^(SRRefreshView* sender) {
[this load]; //replace this line to your refreshing code.
}];
-
Change to style of the slime, You have to get the instance of SRSlimeView by this
refreshView.slime
viscous
this property to set how the limit of the slime being pulled apart.radius
to set the size of slime.bodyColor
to set the fill color.skinColor
to set the line color.
-
How to set the arrow image?
refreshView.refleshView.image
use this to set the arrow image.
Some time you maybe want to add the SRRefreshView
to a UIScrollView
which
have setted the contentInset
. At this time you will set the upInset
, you
just need to set the top.
- call
scrollViewDidScroll
in the protocolscrollViewDidScroll:
ofUIScrollViewDelegate
. - call
scrollViewDidEndDraging
in thescrollViewDidEndDragging:willDecelerate:
. - and if the refresh loading over you will call
endRefresh
.
Ok, that is all. Enjoy it, and this is my blog:http://zhaorenzhi.cn.