完全可自定義下拉刷新iOS控件:CBStoreHouseRefreshControl
這是一個完全可自定義的下拉刷新iOS控件,靈感源于 Storehouse iOS 應用。
你可以通過一個plist文件使用任何形狀,像這樣的這是我公司的標志:
需要什么樣的文件?
你只需要將 CBStoreHouseRefreshControl (.h .m)
包含在你的項目中。
CocoaPods support is coming very soon!
How to use it
You can attach it to any UIScrollView
like UITableView
or UICollectionView
using following simple static method:
+ (CBStoreHouseRefreshControl*)attachToScrollView:(UIScrollView *)scrollView target:(id)target refreshAction:(SEL)refreshAction plist:(NSString *)plist; self.storeHouseRefreshControl = [CBStoreHouseRefreshControl attachToScrollView:self.tableView target:self refreshAction:@selector(refreshTriggered:) plist:@"storehouse"];
Or, using this method for more configurable options:
+ (CBStoreHouseRefreshControl*)attachToScrollView:(UIScrollView *)scrollView target:(id)target refreshAction:(SEL)refreshAction plist:(NSString *)plist color:(UIColor *)color lineWidth:(CGFloat)lineWidth dropHeight:(CGFloat)dropHeight scale:(CGFloat)scale horizontalRandomness:(CGFloat)horizontalRandomness reverseLoadingAnimation:(BOOL)reverseLoadingAnimation internalAnimationFactor:(CGFloat)internalAnimationFactor; self.storeHouseRefreshControl = [CBStoreHouseRefreshControl attachToScrollView:self.tableView target:self refreshAction:@selector(refreshTriggered:) plist:@"storehouse" color:[UIColor whiteColor] lineWidth:1.5 dropHeight:80 scale:1 horizontalRandomness:150 reverseLoadingAnimation:YES internalAnimationFactor:0.5];
Then, implement UIScrollViewDelegate
in your UIViewController
if you haven't already, and pass the calls through to the refresh control:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView { [self.storeHouseRefreshControl scrollViewDidScroll]; } - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate { [self.storeHouseRefreshControl scrollViewDidEndDragging]; }
Lastly, make sure you've implemented the refreshAction
you passed it earlier to listen for refresh triggers:
- (void)refreshTriggered { //call your loading method here //Finshed loading the data, reset the refresh control [self.storeHouseRefreshControl finishedLoading]; }
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!