TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Jul 2015 |
Maintained by Moch, Moch Xiao.
pod 'RefreshControl'
#import "UIScrollView+RefreshControl.h"
TopRefreshControl
__weak typeof(self) weakSelf = self;
[self.tableView addTopRefreshControlUsingBlock:^{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// request for datas
});
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.7 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[weakSelf.tableView reloadData];
[weakSelf.tableView topRefreshControlStopRefreshing];
});
} refreshControlPullType:RefreshControlPullTypeInsensitive refreshControlStatusType:RefreshControlStatusTypeText];
Attention: In call back block, you should reload data first, then stop TopRefreshControl
animation, otherwise, your content focus will go to top.
BottomRefreshControl
__weak typeof(self) weakSelf = self;
[self.tableView addBottomRefreshControlUsingBlock:^{ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// request for datas
});
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[weakSelf.tableView reloadData];
[weakSelf.tableView bottomRefreshControlStopRefreshing];
});
} refreshControlPullType:RefreshControlPullTypeSensitive refreshControlStatusType:RefreshControlStatusTypeText];
Attention: In call back block, you should always reload data first, then stop BottomRefreshControl
animation, otherwise, your content bottom will always go to screen bottom.
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self.tableView topRefreshControlStartInitializeRefreshing];
});
typedef NS_ENUM(NSInteger, RefreshControlPullType) {
RefreshControlPullTypeSensitive,
RefreshControlPullTypeInsensitive
};
typedef NS_ENUM(NSInteger, RefreshControlStatusType) {
RefreshControlStatusTypeTextAndArrow,
RefreshControlStatusTypeText,
RefreshControlStatusTypeArrow
};
Pass refreshControlPullType RefreshControlPullTypeInsensitive
TopRefreshControl
addTopRefreshControlUsingBlock:refreshControlPullType:refreshControlStatusType
BottomRefreshControl
addBottomRefreshControlUsingBlock:refreshControlPullType:refreshControlStatusType
You can change the status text and color, loading animation circle color and arrow color.
@property (nonatomic, strong) NSString *topRefreshControlPullToRefreshingText;
@property (nonatomic, strong) NSString *topRefreshControlPullReleaseToRefreshingText;
@property (nonatomic, strong) NSString *bottomRefreshControlPullToRefreshingText;
@property (nonatomic, strong) NSString *bottomRefreshControlPullReleaseToRefreshingText;
@property (nonatomic, strong) UIColor *statusTextColor;
@property (nonatomic, strong) UIColor *loadingCircleColor;
@property (nonatomic, strong) UIColor *arrowColor;
You can set refresh failure status text
topRefreshControlRefreshFailureWithHintText:
bottomRefreshControlRefreshFailureWithHintText:
You can handle touch event by you self
addTouchUpInsideEventForTopRefreshControlUsingBlock:
addTouchUpInsideEventForBottomRefreshControlUsingBlock:
If you don't handle this event, we will refresh again when you touch RefreshControl or pull again. Of course, after you handle this event, you wanna refresh again, call flow message or pull
topRefreshControlResumeRefreshing
bottomRefreshControlResumeRefreshing