Developer IOS library pull-down refresh-WCPullRefreshControl, ios pull-down refresh
Original Blog, reprinted, please indicate the source
Blog.csdn.net/hello_hwc
My Github
Https://github.com/wenchenhuang/WCPullRefreshControl
Preface:
I have been writing IOS code for a while. It is time to write several Github libraries, that is, to train myself and help people who need it.
This library is a pull-down refresh library. It took about 10 hours to develop it. It made screen adaptation, rotation adaptation, and some animations, the API design was changed three times. Finally, the first version is submitted to Github.
Address
Several Types
Features:
- Screens of various sizes
- Applicable to various scrollviews (UIScrollview, UITableview, UIWebview)
- Supports device Rotation
- Supports a maximum of 12 types of pull-down refreshes (3 types of SS, 4 types of refreshing, 3*4 = 12)
- You can use Block or Delegate to pass events.
- Supports Scrollview with navigation bar
Easy to use
Example 1 Use Block to pass events
The default style is used here.
@interface DemoTableview()<UIScrollViewDelegate>@property (strong,nonatomic)WCSimplePullRefreshControl * pullRefresh;@end@implementation DemoTableview-(void)viewDidLoad{ self.pullRefresh = [[WCSimplePullRefreshControl alloc] initWithScrollview:self.tableView Action:^{ [self performSelector:@selector(reset) withObject:nil afterDelay:2.0]; }];}-(void)reset{ [self.pullRefresh finishRefreshingSuccessully:YES];}-(void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{ [self.pullRefresh updateWHenScrollDidEndDraging];}-(void)scrollViewDidScroll:(UIScrollView *)scrollView{ [self.pullRefresh updateWhenScrollviewScroll];}
Method 2: Use a proxy to pass events
Customized Style
@interface DemoTableview()<UIScrollViewDelegate,WCPullRefreshControlDelegate>@property (strong,nonatomic)WCSimplePullRefreshControl * pullRefresh;@end@implementation DemoTableview-(void)viewDidLoad{ self.pullRefresh = [[WCSimplePullRefreshControl alloc] initWithScrollview:self.tableView Action:NULL progressItem:WCProgressItemTypeMagicSquare refreshingItem:WCRefreshingItemTypeMagicSquare lastUpdate:nil showLastUpdate:NO textColor:[UIColor blueColor] itemColor:[UIColor grayColor] pullHeight:64];self.pullRefresh.delegate = self;}-(void)reset{ [self.pullRefresh finishRefreshingSuccessully:YES];}-(void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{ [self.pullRefresh updateWHenScrollDidEndDraging];}-(void)scrollViewDidScroll:(UIScrollView *)scrollView{ [self.pullRefresh updateWhenScrollviewScroll];}-(void)DidStartRefreshingWithScrollview:(UIScrollView *)scrollview{ [self performSelector:@selector(reset) withObject:nil afterDelay:2.0];}@end
Follow-up
If a bug is found, leave a message in this blog or email: njuhwc@163.com