├── .DS_Store ├── BIRefreshControlDemo ├── .DS_Store ├── BIRefreshControl │ ├── BIInputMehodLoadingFooter.h │ ├── BIInputMehodLoadingFooter.m │ ├── BIInputMethodRefreshHeader.h │ ├── BIInputMethodRefreshHeader.m │ ├── BILoadingFooter.h │ ├── BILoadingFooter.m │ ├── BIRefresh.h │ ├── BIRefreshHeader.h │ ├── BIRefreshHeader.m │ ├── NSString+Path.h │ ├── NSString+Path.m │ ├── UIScrollView+BICustomRefreshControl.h │ ├── UIScrollView+BICustomRefreshControl.m │ ├── UIScrollView+BIRefreshControl.h │ └── UIScrollView+BIRefreshControl.m ├── BIRefreshControlDemo.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── August.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── August.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ ├── BIRefreshControlDemo.xcscheme │ │ └── xcschememanagement.plist ├── BIRefreshControlDemo │ ├── .DS_Store │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── BIInputMehodLoadingFooter.h │ ├── BIInputMehodLoadingFooter.m │ ├── BIInputMethodRefreshHeader.h │ ├── BIInputMethodRefreshHeader.m │ ├── BILoadingFooter.h │ ├── BILoadingFooter.m │ ├── BIRefresh.h │ ├── BIRefreshHeader.h │ ├── BIRefreshHeader.m │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Info.plist │ ├── UIScrollView+BICustomRefreshControl.h │ ├── UIScrollView+BICustomRefreshControl.m │ ├── UIScrollView+BIRefreshControl.h │ ├── UIScrollView+BIRefreshControl.m │ ├── ViewController.h │ ├── ViewController.m │ └── main.m ├── BIRefreshControlDemoTests │ ├── BIRefreshControlDemoTests.m │ └── Info.plist └── BIRefreshControlDemoUITests │ ├── BIRefreshControlDemoUITests.m │ └── Info.plist ├── README.md └── rotaion.gif /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AugustRush/BIRefreshControl/7cfc352aee9449d2e4a3487030081cd18a25ddfc/.DS_Store -------------------------------------------------------------------------------- /BIRefreshControlDemo/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AugustRush/BIRefreshControl/7cfc352aee9449d2e4a3487030081cd18a25ddfc/BIRefreshControlDemo/.DS_Store -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControl/BIInputMehodLoadingFooter.h: -------------------------------------------------------------------------------- 1 | // 2 | // BIInputMehodLoadingFooter.h 3 | // BIRefreshControlDemo 4 | // 5 | // Created by AugustRush on 11/25/15. 6 | // Copyright © 2015 AugustRush. All rights reserved. 7 | // 8 | 9 | #import "BILoadingFooter.h" 10 | 11 | @interface BIInputMehodLoadingFooter : BILoadingFooter 12 | 13 | @property (nonatomic, copy) NSString *loadingAnimatedText; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControl/BIInputMehodLoadingFooter.m: -------------------------------------------------------------------------------- 1 | // 2 | // BIInputMehodLoadingFooter.m 3 | // BIRefreshControlDemo 4 | // 5 | // Created by AugustRush on 11/25/15. 6 | // Copyright © 2015 AugustRush. All rights reserved. 7 | // 8 | 9 | #import "BIInputMehodLoadingFooter.h" 10 | #import "NSString+Path.h" 11 | 12 | @implementation BIInputMehodLoadingFooter 13 | 14 | - (instancetype)init { 15 | self = [super init]; 16 | if (self) { 17 | [self setUp]; 18 | } 19 | return self; 20 | } 21 | 22 | + (Class)layerClass { 23 | return [CAShapeLayer class]; 24 | } 25 | 26 | #pragma mark - private methods 27 | 28 | - (void)setUp { 29 | _loadingAnimatedText = @"Just Loading text"; 30 | self.delegate = self; 31 | self.backgroundColor = [UIColor whiteColor]; 32 | CAShapeLayer *layer = (CAShapeLayer *)self.layer; 33 | layer.strokeColor = [UIColor colorWithRed:252/255.0 green:70/255.0 blue:209/255.0 alpha:1].CGColor; 34 | layer.lineCap = kCALineCapRound; 35 | layer.lineWidth = 3; 36 | layer.fillColor = [UIColor clearColor].CGColor; 37 | layer.autoreverses = YES; 38 | layer.path = [_loadingAnimatedText bezierPathWithFont:[UIFont fontWithName:@"noteworthy" size:48]].CGPath; 39 | } 40 | 41 | #pragma mark - BILoadingFooterDelegate methods 42 | 43 | - (void)loadingFooter:(BILoadingFooter *)footer didChangedLoadingProgress:(CGFloat)progress { 44 | CAShapeLayer *layer = (CAShapeLayer *)self.layer; 45 | if (self.state != BILoadingFooterStateLoading) { 46 | layer.strokeEnd = progress - 0.5; 47 | }else{ 48 | layer.strokeEnd = 1.5; 49 | } 50 | } 51 | 52 | - (void)loadingFooter:(BILoadingFooter *)footer didChangedLoadingState:(BILoadingFooterState)state { 53 | switch (state) { 54 | case BILoadingFooterStateInitial: { 55 | 56 | break; 57 | } 58 | case BILoadingFooterStateLoading: 59 | case BILoadingFooterStateFinished: { 60 | [self loadingFooter:footer didChangedLoadingProgress:1.5]; 61 | break; 62 | } 63 | } 64 | } 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControl/BIInputMethodRefreshHeader.h: -------------------------------------------------------------------------------- 1 | // 2 | // BIInputMethodRefreshHeader.h 3 | // BIRefreshHeaderDemo 4 | // 5 | // Created by AugustRush on 11/25/15. 6 | // Copyright © 2015 AugustRush. All rights reserved. 7 | // 8 | 9 | #import "BIRefreshHeader.h" 10 | 11 | @interface BIInputMethodRefreshHeader : BIRefreshHeader 12 | 13 | @property (nonatomic, copy) NSString *refreshAnimatedText; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControl/BIInputMethodRefreshHeader.m: -------------------------------------------------------------------------------- 1 | // 2 | // BIInputMethodRefreshHeader.m 3 | // BIRefreshHeaderDemo 4 | // 5 | // Created by AugustRush on 11/25/15. 6 | // Copyright © 2015 AugustRush. All rights reserved. 7 | // 8 | 9 | #import "BIInputMethodRefreshHeader.h" 10 | #import "NSString+Path.h" 11 | 12 | @implementation BIInputMethodRefreshHeader 13 | 14 | #pragma mark - init methods 15 | 16 | - (instancetype)init { 17 | self = [super init]; 18 | if (self) { 19 | [self setUp]; 20 | } 21 | return self; 22 | } 23 | 24 | + (Class)layerClass { 25 | return [CAShapeLayer class]; 26 | } 27 | 28 | #pragma mark - private methods 29 | 30 | - (void)setUp { 31 | _refreshAnimatedText = @"**** Refreshing ****"; 32 | self.delegate = self; 33 | self.clipsToBounds = YES; 34 | self.backgroundColor = [UIColor whiteColor]; 35 | CAShapeLayer *layer = (CAShapeLayer *)self.layer; 36 | layer.strokeColor = [UIColor colorWithRed:252/255.0 green:70/255.0 blue:209/255.0 alpha:1].CGColor; 37 | layer.lineCap = kCALineCapRound; 38 | layer.lineWidth = 3; 39 | layer.fillColor = [UIColor clearColor].CGColor; 40 | layer.autoreverses = YES; 41 | layer.path = [_refreshAnimatedText bezierPathWithFont:[UIFont fontWithName:@"Snell Roundhand" size:40]].CGPath; 42 | } 43 | 44 | #pragma mark - BIRefreshHeaderDelegate methods 45 | 46 | - (void)refreshControl:(BIRefreshHeader *)control didChangeRefreshProgress:(CGFloat)progress { 47 | CAShapeLayer *layer = (CAShapeLayer *)self.layer; 48 | if (self.state != BIRefreshHeaderStateRefreshing) { 49 | layer.strokeEnd = progress - 0.5; 50 | }else{ 51 | layer.strokeEnd = 1.5; 52 | } 53 | } 54 | 55 | - (void)refreshControl:(BIRefreshHeader *)control didChangeRefreshState:(BIRefreshHeaderState)state { 56 | switch (state) { 57 | case BIRefreshHeaderStateInitial: { 58 | 59 | break; 60 | } 61 | case BIRefreshHeaderStateRefreshing: 62 | case BIRefreshHeaderStateFinished: { 63 | [self refreshControl:control didChangeRefreshProgress:1.5]; 64 | break; 65 | } 66 | default: { 67 | break; 68 | } 69 | } 70 | } 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControl/BILoadingFooter.h: -------------------------------------------------------------------------------- 1 | // 2 | // BILoadingControl.h 3 | // BIRefreshHeaderDemo 4 | // 5 | // Created by AugustRush on 11/25/15. 6 | // Copyright © 2015 AugustRush. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef NS_ENUM(NSUInteger, BILoadingFooterState) { 12 | BILoadingFooterStateInitial, 13 | BILoadingFooterStateLoading, 14 | BILoadingFooterStateFinished, 15 | }; 16 | 17 | @protocol BILoadingFooterDelegate; 18 | 19 | @interface BILoadingFooter : UIView 20 | 21 | @property (nonatomic, weak) id delegate; 22 | @property (nonatomic, assign) BILoadingFooterState state; 23 | @property (nonatomic, assign) CGFloat offsetThreshold; 24 | @property (nonatomic, copy) void (^loadingHandler)(void); 25 | 26 | - (void)startLoading; 27 | - (void)stopLoading; 28 | 29 | @end 30 | 31 | @protocol BILoadingFooterDelegate 32 | 33 | @optional 34 | - (void)loadingFooter:(BILoadingFooter *)footer didChangedLoadingProgress:(CGFloat)progress; 35 | - (void)loadingFooter:(BILoadingFooter *)footer didChangedLoadingState:(BILoadingFooterState)state; 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControl/BILoadingFooter.m: -------------------------------------------------------------------------------- 1 | // 2 | // BILoadingControl.m 3 | // BIRefreshHeaderDemo 4 | // 5 | // Created by AugustRush on 11/25/15. 6 | // Copyright © 2015 AugustRush. All rights reserved. 7 | // 8 | 9 | #import "BILoadingFooter.h" 10 | #import "BIRefresh.h" 11 | #import "BIRefreshHeader.h" 12 | 13 | static void *BILoadingFooterObserverContentSizeContext = &BILoadingFooterObserverContentSizeContext; 14 | static void *BILoadingFooterObserverContentOffsetContext = &BILoadingFooterObserverContentOffsetContext; 15 | 16 | @interface BILoadingFooter () 17 | 18 | @property (nonatomic, weak) UIScrollView *scrollView; 19 | @property (nonatomic, assign) UIEdgeInsets origianlInset; 20 | @property (nonatomic, weak) NSLayoutConstraint *topConstraint; 21 | 22 | @end 23 | 24 | @implementation BILoadingFooter 25 | 26 | #pragma mark - init methods 27 | 28 | - (instancetype)init { 29 | self = [super init]; 30 | if (self) { 31 | self.state = BILoadingFooterStateInitial; 32 | } 33 | return self; 34 | } 35 | 36 | - (instancetype)initWithCoder:(NSCoder *)aDecoder { 37 | self = [super initWithCoder:aDecoder]; 38 | if (self) { 39 | self.state = BILoadingFooterStateInitial; 40 | } 41 | return self; 42 | } 43 | 44 | #pragma mark - override methods 45 | 46 | - (void)willMoveToSuperview:(UIView *)newSuperview { 47 | [super willMoveToSuperview:newSuperview]; 48 | 49 | if (self.superview) { 50 | [self removeLoadingControlObservers]; 51 | } 52 | 53 | if (self.superview == nil && [newSuperview isKindOfClass:[UIScrollView class]]) { 54 | self.scrollView = (UIScrollView *)newSuperview; 55 | self.origianlInset = self.scrollView.contentInset; 56 | [self addRefreshControlObservers]; 57 | } 58 | } 59 | 60 | #pragma mark - private methods 61 | 62 | - (void)removeLoadingControlObservers { 63 | @try { 64 | [self.superview removeObserver:self forKeyPath:NSStringFromSelector(@selector(contentSize))]; 65 | [self.superview removeObserver:self forKeyPath:NSStringFromSelector(@selector(contentOffset))]; 66 | } 67 | @catch (NSException *exception) { 68 | } 69 | @finally { 70 | } 71 | } 72 | 73 | - (void)addRefreshControlObservers { 74 | [self.scrollView addObserver:self forKeyPath:NSStringFromSelector(@selector(contentSize)) options:NSKeyValueObservingOptionNew context:BILoadingFooterObserverContentSizeContext]; 75 | [self.scrollView addObserver:self forKeyPath:NSStringFromSelector(@selector(contentOffset)) options:NSKeyValueObservingOptionNew context:BILoadingFooterObserverContentOffsetContext]; 76 | } 77 | 78 | - (void)springAnimation:(void(^)(void))animation completion:(void(^)(BOOL finished))completion { 79 | [UIView animateWithDuration:kBIRefreshHeaderAnimateInterval 80 | delay:0.0 81 | usingSpringWithDamping:1.0 82 | initialSpringVelocity:0.2 83 | options:UIViewAnimationOptionCurveEaseOut 84 | animations:animation 85 | completion:completion]; 86 | 87 | } 88 | 89 | - (BOOL)canLoading { 90 | return self.scrollView.refreshHeader.state != BIRefreshHeaderStateRefreshing; 91 | } 92 | 93 | #pragma mark - NSKeyValueObserving method 94 | 95 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { 96 | if (context == BILoadingFooterObserverContentSizeContext) { 97 | CGSize newSize = [change[NSKeyValueChangeNewKey] CGSizeValue]; 98 | // 99 | self.topConstraint.constant = MAX(newSize.height + self.origianlInset.top, CGRectGetHeight(self.scrollView.bounds)); 100 | [self.scrollView bringSubviewToFront:self]; 101 | }else if (context == BILoadingFooterObserverContentOffsetContext) { 102 | CGPoint offset = [change[NSKeyValueChangeNewKey] CGPointValue]; 103 | CGFloat contentHeight = MAX(self.scrollView.contentSize.height, CGRectGetHeight(self.scrollView.bounds)); 104 | CGFloat progress = (offset.y + CGRectGetHeight(self.scrollView.bounds) - contentHeight)/self.offsetThreshold; 105 | if (offset.y > 0 && 106 | progress > 1 && 107 | self.scrollView.isTracking == NO) { 108 | [self startLoading]; 109 | } 110 | if (offset.y > 0 && 111 | [self.delegate respondsToSelector:@selector(loadingFooter:didChangedLoadingProgress:)]) { 112 | if (progress < 0) { 113 | progress = 0; 114 | } 115 | //if it's loading just make progress as 1 116 | [self.delegate loadingFooter:self didChangedLoadingProgress:(_state == BILoadingFooterStateLoading) ? 1:progress]; 117 | } 118 | } 119 | } 120 | 121 | #pragma mark - public methods 122 | 123 | - (void)startLoading { 124 | if (self.state != BILoadingFooterStateLoading && 125 | [self canLoading]) { 126 | self.state = BILoadingFooterStateLoading; 127 | self.scrollView.bounces = NO; 128 | //when contentSize.height < scrollView.bounds.size.height 129 | CGFloat height = CGRectGetHeight(self.scrollView.bounds) - self.origianlInset.top - self.origianlInset.bottom - self.scrollView.contentSize.height; 130 | if (height < 0) { 131 | height = 0; 132 | } 133 | [self springAnimation:^{ 134 | UIEdgeInsets inset = self.origianlInset; 135 | inset.bottom += (self.offsetThreshold + height); 136 | [self.scrollView setContentInset:inset]; 137 | } completion:^(BOOL finished) { 138 | self.scrollView.bounces = YES; 139 | if (self.loadingHandler) { 140 | self.loadingHandler(); 141 | } 142 | }]; 143 | } 144 | } 145 | 146 | - (void)stopLoading { 147 | if (self.state != BILoadingFooterStateFinished) { 148 | [self springAnimation:^{ 149 | [self.scrollView setContentInset:self.origianlInset]; 150 | } completion:^(BOOL finished) { 151 | self.state = BILoadingFooterStateFinished; 152 | }]; 153 | } 154 | } 155 | 156 | @end 157 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControl/BIRefresh.h: -------------------------------------------------------------------------------- 1 | // 2 | // BIRefresh.h 3 | // BIRefreshControlDemo 4 | // 5 | // Created by AugustRush on 11/25/15. 6 | // Copyright © 2015 AugustRush. All rights reserved. 7 | // 8 | 9 | #ifndef BIRefresh_h 10 | #define BIRefresh_h 11 | 12 | #import "UIScrollView+BIRefreshControl.h" 13 | #import "UIScrollView+BICustomRefreshControl.h" 14 | 15 | #define kBIRefreshHeaderAnimateInterval 0.5 16 | 17 | #endif /* BIRefresh_h */ 18 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControl/BIRefreshHeader.h: -------------------------------------------------------------------------------- 1 | // 2 | // BIRefreshHeader.h 3 | // BIRefreshHeaderDemo 4 | // 5 | // Created by AugustRush on 11/24/15. 6 | // Copyright © 2015 AugustRush. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef NS_ENUM(NSUInteger, BIRefreshHeaderState) { 12 | BIRefreshHeaderStateInitial, 13 | BIRefreshHeaderStateRefreshing, 14 | BIRefreshHeaderStateFinished, 15 | }; 16 | 17 | @protocol BIRefreshHeaderDelegate; 18 | 19 | @interface BIRefreshHeader : UIView 20 | 21 | @property (nonatomic, weak) id delegate; 22 | @property (nonatomic, assign, readonly) BIRefreshHeaderState state; 23 | @property (nonatomic, assign) CGFloat offsetThreshold; 24 | @property (nonatomic, copy) void(^refreshHandler)(void); 25 | 26 | - (void)startRefreshing; 27 | - (void)stopRefreshing; 28 | 29 | @end 30 | 31 | @protocol BIRefreshHeaderDelegate 32 | 33 | @optional 34 | - (void)refreshControl:(BIRefreshHeader *)control didChangeRefreshProgress:(CGFloat)progress; 35 | - (void)refreshControl:(BIRefreshHeader *)control didChangeRefreshState:(BIRefreshHeaderState)state; 36 | 37 | @end -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControl/BIRefreshHeader.m: -------------------------------------------------------------------------------- 1 | // 2 | // BIRefreshHeader.m 3 | // BIRefreshHeaderDemo 4 | // 5 | // Created by AugustRush on 11/24/15. 6 | // Copyright © 2015 AugustRush. All rights reserved. 7 | // 8 | 9 | #import "BIRefreshHeader.h" 10 | #import "BIRefresh.h" 11 | #import "BILoadingFooter.h" 12 | 13 | static void *BIRefreshHeaderObserverContentOffsetContext = &BIRefreshHeaderObserverContentOffsetContext; 14 | 15 | @interface BIRefreshHeader () 16 | 17 | @property (nonatomic, assign) BIRefreshHeaderState state; 18 | @property (nonatomic, weak) UIScrollView *scrollView; 19 | @property (nonatomic, assign) UIEdgeInsets originalInset; 20 | 21 | @end 22 | 23 | @implementation BIRefreshHeader 24 | 25 | #pragma mark - init methods 26 | 27 | - (instancetype)init { 28 | self = [super init]; 29 | if (self) { 30 | self.state = BIRefreshHeaderStateInitial; 31 | } 32 | return self; 33 | } 34 | 35 | - (instancetype)initWithCoder:(NSCoder *)aDecoder { 36 | self = [super initWithCoder:aDecoder]; 37 | if (self) { 38 | self.state = BIRefreshHeaderStateInitial; 39 | } 40 | return self; 41 | } 42 | 43 | #pragma mark - override methods 44 | 45 | - (void)willMoveToSuperview:(UIView *)newSuperview { 46 | [super willMoveToSuperview:newSuperview]; 47 | 48 | if (self.superview) { 49 | [self removeRefreshControlObservers]; 50 | } 51 | 52 | if (self.superview == nil && [newSuperview isKindOfClass:[UIScrollView class]]) { 53 | self.scrollView = (UIScrollView *)newSuperview; 54 | self.originalInset = self.scrollView.contentInset; 55 | [self addRefreshControlObservers]; 56 | } 57 | } 58 | 59 | #pragma mark - private methods 60 | 61 | - (void)addRefreshControlObservers { 62 | [self.scrollView addObserver:self forKeyPath:NSStringFromSelector(@selector(contentOffset)) options:NSKeyValueObservingOptionNew context:BIRefreshHeaderObserverContentOffsetContext]; 63 | } 64 | 65 | - (void)removeRefreshControlObservers { 66 | //must use superView to remove observers, why? 67 | @try { 68 | [self.superview removeObserver:self forKeyPath:NSStringFromSelector(@selector(contentOffset))]; 69 | } 70 | @catch (NSException *exception) { 71 | } 72 | @finally { 73 | } 74 | } 75 | 76 | - (void)springAnimation:(void(^)(void))animation completion:(void(^)(BOOL finished))completion { 77 | [UIView animateWithDuration:kBIRefreshHeaderAnimateInterval 78 | delay:0.0 79 | usingSpringWithDamping:1.0 80 | initialSpringVelocity:0.2 81 | options:UIViewAnimationOptionCurveEaseOut 82 | animations:animation 83 | completion:completion]; 84 | 85 | } 86 | 87 | - (void)setState:(BIRefreshHeaderState)state { 88 | _state = state; 89 | if ([self.delegate respondsToSelector:@selector(refreshControl:didChangeRefreshState:)]) { 90 | [self.delegate refreshControl:self didChangeRefreshState:_state]; 91 | } 92 | } 93 | 94 | - (BOOL)canRefresh { 95 | return self.scrollView.loadingFooter.state != BILoadingFooterStateLoading; 96 | } 97 | 98 | #pragma mark - NSKeyValueObserving methods 99 | 100 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { 101 | if (context == BIRefreshHeaderObserverContentOffsetContext) { 102 | CGPoint offset = [change[NSKeyValueChangeNewKey] CGPointValue]; 103 | CGFloat progress = -offset.y/self.offsetThreshold; 104 | if (progress > 1 && 105 | self.scrollView.isTracking == NO) { 106 | [self startRefreshing]; 107 | } 108 | if (offset.y < 0 && 109 | [self.delegate respondsToSelector:@selector(refreshControl:didChangeRefreshProgress:)]) { 110 | if (progress < 0) { 111 | progress = 0; 112 | } 113 | [self.delegate refreshControl:self didChangeRefreshProgress:(_state == BIRefreshHeaderStateRefreshing) ? 1:progress]; 114 | } 115 | } 116 | } 117 | 118 | #pragma mark - public methods 119 | 120 | - (void)stopRefreshing { 121 | if (self.state != BIRefreshHeaderStateFinished) { 122 | [self springAnimation:^{ 123 | [self.scrollView setContentInset:self.originalInset]; 124 | } completion:^(BOOL finished) { 125 | self.state = BIRefreshHeaderStateFinished; 126 | }]; 127 | } 128 | } 129 | 130 | - (void)startRefreshing { 131 | if (self.state != BIRefreshHeaderStateRefreshing && 132 | [self canRefresh]) { 133 | self.state = BIRefreshHeaderStateRefreshing; 134 | self.scrollView.bounces = NO; 135 | [self springAnimation:^{ 136 | [self.scrollView setContentInset:UIEdgeInsetsMake(_offsetThreshold, 0, 0, 0)]; 137 | self.scrollView.contentOffset = CGPointMake(0, -_offsetThreshold); 138 | } completion:^(BOOL finished) { 139 | self.scrollView.bounces = YES; 140 | if (self.refreshHandler) { 141 | self.refreshHandler(); 142 | } 143 | }]; 144 | } 145 | } 146 | 147 | @end 148 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControl/NSString+Path.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+Path.h 3 | // BIRefreshControlDemo 4 | // 5 | // Created by AugustRush on 12/28/15. 6 | // Copyright © 2015 AugustRush. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSString (Path) 12 | 13 | - (UIBezierPath*)bezierPathWithFont:(UIFont*)font; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControl/NSString+Path.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+Path.m 3 | // BIRefreshControlDemo 4 | // 5 | // Created by AugustRush on 12/28/15. 6 | // Copyright © 2015 AugustRush. All rights reserved. 7 | // 8 | 9 | #import "NSString+Path.h" 10 | #import 11 | 12 | @implementation NSString (Path) 13 | 14 | - (UIBezierPath*)bezierPathWithFont:(UIFont*)font { 15 | CTFontRef ctFont = CTFontCreateWithName((__bridge CFStringRef)font.fontName, font.pointSize, NULL); 16 | NSAttributedString *attributed = [[NSAttributedString alloc] initWithString:self attributes:[NSDictionary dictionaryWithObject:(__bridge id)ctFont forKey:(__bridge NSString*)kCTFontAttributeName]]; 17 | CFRelease(ctFont); 18 | 19 | CGMutablePathRef letters = CGPathCreateMutable(); 20 | CTLineRef line = CTLineCreateWithAttributedString((__bridge CFAttributedStringRef)attributed); 21 | CFArrayRef runArray = CTLineGetGlyphRuns(line); 22 | for (CFIndex runIndex = 0; runIndex < CFArrayGetCount(runArray); runIndex++) 23 | { 24 | CTRunRef run = (CTRunRef)CFArrayGetValueAtIndex(runArray, runIndex); 25 | CTFontRef runFont = CFDictionaryGetValue(CTRunGetAttributes(run), kCTFontAttributeName); 26 | 27 | for (CFIndex runGlyphIndex = 0; runGlyphIndex < CTRunGetGlyphCount(run); runGlyphIndex++) 28 | { 29 | CFRange thisGlyphRange = CFRangeMake(runGlyphIndex, 1); 30 | CGGlyph glyph; 31 | CGPoint position; 32 | CTRunGetGlyphs(run, thisGlyphRange, &glyph); 33 | CTRunGetPositions(run, thisGlyphRange, &position); 34 | 35 | CGPathRef letter = CTFontCreatePathForGlyph(runFont, glyph, NULL); 36 | CGAffineTransform t = CGAffineTransformMakeTranslation(position.x, position.y); 37 | CGPathAddPath(letters, &t, letter); 38 | CGPathRelease(letter); 39 | } 40 | } 41 | 42 | UIBezierPath *path = [UIBezierPath bezierPathWithCGPath:letters]; 43 | CGRect boundingBox = CGPathGetBoundingBox(letters); 44 | CGPathRelease(letters); 45 | CFRelease(line); 46 | 47 | // The path is upside down (CG coordinate system) 48 | [path applyTransform:CGAffineTransformMakeScale(1.0, -1.0)]; 49 | [path applyTransform:CGAffineTransformMakeTranslation(0.0, boundingBox.size.height)]; 50 | 51 | return path; 52 | } 53 | 54 | @end 55 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControl/UIScrollView+BICustomRefreshControl.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIScrollView+BICustomRefreshControl.h 3 | // BIRefreshHeaderDemo 4 | // 5 | // Created by AugustRush on 11/25/15. 6 | // Copyright © 2015 AugustRush. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "UIScrollView+BIRefreshControl.h" 11 | 12 | @interface UIScrollView (BICustomRefreshControl) 13 | 14 | - (void)bi_addInputMethodRefreshHeaderWithHandler:(void (^)(void))handler; 15 | - (void)bi_addInputMethodLoadingFooterWithHandler:(void (^)(void))handler; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControl/UIScrollView+BICustomRefreshControl.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIScrollView+BICustomRefreshControl.m 3 | // BIRefreshHeaderDemo 4 | // 5 | // Created by AugustRush on 11/25/15. 6 | // Copyright © 2015 AugustRush. All rights reserved. 7 | // 8 | 9 | #import "UIScrollView+BICustomRefreshControl.h" 10 | #import "BIInputMethodRefreshHeader.h" 11 | #import "BIInputMehodLoadingFooter.h" 12 | 13 | @implementation UIScrollView (BICustomRefreshControl) 14 | 15 | - (void)bi_addInputMethodRefreshHeaderWithHandler:(void (^)(void))handler { 16 | BIInputMethodRefreshHeader *header = [[BIInputMethodRefreshHeader alloc] init]; 17 | [self bi_addRefreshHeaderWithControl:header Height:100 refreshHandler:handler]; 18 | } 19 | 20 | - (void)bi_addInputMethodLoadingFooterWithHandler:(void (^)(void))handler { 21 | BIInputMehodLoadingFooter *footer = [[BIInputMehodLoadingFooter alloc] init]; 22 | [self bi_addLoadingFooterWithControl:footer height:100 loadingHandler:handler]; 23 | } 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControl/UIScrollView+BIRefreshControl.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIScrollView+BIRefreshHeader.h 3 | // BIRefreshHeaderDemo 4 | // 5 | // Created by AugustRush on 11/24/15. 6 | // Copyright © 2015 AugustRush. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "BIRefreshHeader.h" 11 | #import "BILoadingFooter.h" 12 | 13 | @interface UIScrollView (BIRefreshControl) 14 | 15 | @property (readonly) BIRefreshHeader *refreshHeader; 16 | @property (readonly) BILoadingFooter *loadingFooter; 17 | 18 | - (void)bi_addRefreshHeaderWithControl:(BIRefreshHeader *)control 19 | Height:(CGFloat)height 20 | refreshHandler:(void (^)(void))handler; 21 | 22 | - (void)bi_addLoadingFooterWithControl:(BILoadingFooter *)control 23 | height:(CGFloat)height 24 | loadingHandler:(void (^)(void))handler; 25 | 26 | //header 27 | - (void)bi_startRefreshing; 28 | - (void)bi_stopRefreshing; 29 | 30 | //footer 31 | - (void)bi_startLoading; 32 | - (void)bi_stopLoading; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControl/UIScrollView+BIRefreshControl.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIScrollView+BIRefreshHeader.m 3 | // BIRefreshHeaderDemo 4 | // 5 | // Created by AugustRush on 11/24/15. 6 | // Copyright © 2015 AugustRush. All rights reserved. 7 | // 8 | 9 | #import "UIScrollView+BIRefreshControl.h" 10 | #import 11 | 12 | @interface UIScrollView (BIRefreshExtension) 13 | 14 | @end 15 | 16 | @implementation UIScrollView (BIRefreshExtension) 17 | 18 | - (void)setRefreshHeader:(BIRefreshHeader *)refreshHeader { 19 | objc_setAssociatedObject(self, @selector(refreshHeader), refreshHeader, 20 | OBJC_ASSOCIATION_ASSIGN); 21 | } 22 | 23 | - (BIRefreshHeader *)refreshHeader { 24 | return objc_getAssociatedObject(self, _cmd); 25 | } 26 | 27 | - (void)setLoadingFooter:(BILoadingFooter *)loadingFooter { 28 | objc_setAssociatedObject(self, @selector(loadingFooter), loadingFooter, 29 | OBJC_ASSOCIATION_ASSIGN); 30 | } 31 | 32 | - (BILoadingFooter *)loadingFooter { 33 | return objc_getAssociatedObject(self, _cmd); 34 | } 35 | 36 | @end 37 | 38 | @implementation UIScrollView (BIRefreshHeader) 39 | 40 | #pragma mark - public methods 41 | 42 | - (void)bi_addRefreshHeaderWithControl:(BIRefreshHeader *)control 43 | Height:(CGFloat)height 44 | refreshHandler:(void (^)(void))handler { 45 | if (self.refreshHeader != nil) { 46 | [self.refreshHeader removeFromSuperview]; 47 | self.refreshHeader = nil; 48 | } 49 | control.refreshHandler = handler; 50 | control.offsetThreshold = height; 51 | [self addSubview:control]; 52 | // associate 53 | self.refreshHeader = control; 54 | // layout 55 | [self initializeLayoutWithRefreshControl:control height:height]; 56 | } 57 | 58 | - (void)bi_addLoadingFooterWithControl:(BILoadingFooter *)control 59 | height:(CGFloat)height 60 | loadingHandler:(void (^)(void))handler { 61 | if (self.loadingFooter != nil) { 62 | [self.loadingFooter removeFromSuperview]; 63 | self.loadingFooter = nil; 64 | } 65 | control.loadingHandler = handler; 66 | control.offsetThreshold = height; 67 | [self addSubview:control]; 68 | 69 | // associate 70 | self.loadingFooter = control; 71 | // layout 72 | [self initializeLayoutWithLoadingControl:control height:height]; 73 | } 74 | 75 | - (void)bi_startRefreshing { 76 | [self.refreshHeader startRefreshing]; 77 | } 78 | 79 | - (void)bi_stopRefreshing { 80 | [self.refreshHeader stopRefreshing]; 81 | } 82 | 83 | - (void)bi_startLoading { 84 | [self.loadingFooter startLoading]; 85 | } 86 | 87 | - (void)bi_stopLoading { 88 | [self.loadingFooter stopLoading]; 89 | } 90 | 91 | #pragma mark - private methods 92 | 93 | - (void)initializeLayoutWithRefreshControl:(BIRefreshHeader *)control 94 | height:(CGFloat)height { 95 | control.translatesAutoresizingMaskIntoConstraints = NO; 96 | 97 | NSLayoutConstraint *leftConstraint = 98 | [NSLayoutConstraint constraintWithItem:control 99 | attribute:NSLayoutAttributeLeft 100 | relatedBy:NSLayoutRelationEqual 101 | toItem:self 102 | attribute:NSLayoutAttributeLeft 103 | multiplier:1 104 | constant:0]; 105 | 106 | NSLayoutConstraint *topConstraint = 107 | [NSLayoutConstraint constraintWithItem:control 108 | attribute:NSLayoutAttributeTop 109 | relatedBy:NSLayoutRelationEqual 110 | toItem:self 111 | attribute:NSLayoutAttributeTop 112 | multiplier:1 113 | constant:-height]; 114 | NSLayoutConstraint *rightConstraint = 115 | [NSLayoutConstraint constraintWithItem:control 116 | attribute:NSLayoutAttributeRight 117 | relatedBy:NSLayoutRelationEqual 118 | toItem:self 119 | attribute:NSLayoutAttributeRight 120 | multiplier:1 121 | constant:0]; 122 | NSLayoutConstraint *heightConstraint = 123 | [NSLayoutConstraint constraintWithItem:control 124 | attribute:NSLayoutAttributeHeight 125 | relatedBy:NSLayoutRelationEqual 126 | toItem:nil 127 | attribute:NSLayoutAttributeNotAnAttribute 128 | multiplier:1 129 | constant:height]; 130 | // must add width constraint for control,because scrollView's width up to its 131 | // subViews 132 | NSLayoutConstraint *widthConstraint = 133 | [NSLayoutConstraint constraintWithItem:control 134 | attribute:NSLayoutAttributeWidth 135 | relatedBy:NSLayoutRelationEqual 136 | toItem:self 137 | attribute:NSLayoutAttributeWidth 138 | multiplier:1 139 | constant:0]; 140 | 141 | [self addConstraints:@[ 142 | leftConstraint, 143 | topConstraint, 144 | rightConstraint, 145 | heightConstraint, 146 | widthConstraint 147 | ]]; 148 | } 149 | 150 | - (void)initializeLayoutWithLoadingControl:(BILoadingFooter *)control 151 | height:(CGFloat)height { 152 | control.translatesAutoresizingMaskIntoConstraints = NO; 153 | 154 | NSLayoutConstraint *leftConstraint = 155 | [NSLayoutConstraint constraintWithItem:control 156 | attribute:NSLayoutAttributeLeft 157 | relatedBy:NSLayoutRelationEqual 158 | toItem:self 159 | attribute:NSLayoutAttributeLeft 160 | multiplier:1 161 | constant:0]; 162 | 163 | NSLayoutConstraint *topConstraint = 164 | [NSLayoutConstraint constraintWithItem:control 165 | attribute:NSLayoutAttributeTop 166 | relatedBy:NSLayoutRelationEqual 167 | toItem:self 168 | attribute:NSLayoutAttributeTop 169 | multiplier:1 170 | constant:0]; 171 | [self.loadingFooter 172 | setValue:topConstraint 173 | forKey:@"topConstraint"]; // assignment an private property 174 | NSLayoutConstraint *rightConstraint = 175 | [NSLayoutConstraint constraintWithItem:control 176 | attribute:NSLayoutAttributeRight 177 | relatedBy:NSLayoutRelationEqual 178 | toItem:self 179 | attribute:NSLayoutAttributeRight 180 | multiplier:1 181 | constant:0]; 182 | NSLayoutConstraint *heightConstraint = 183 | [NSLayoutConstraint constraintWithItem:control 184 | attribute:NSLayoutAttributeHeight 185 | relatedBy:NSLayoutRelationEqual 186 | toItem:nil 187 | attribute:NSLayoutAttributeNotAnAttribute 188 | multiplier:1 189 | constant:height]; 190 | // must add width constraint for control,because scrollView's width up to its 191 | // subViews 192 | NSLayoutConstraint *widthConstraint = 193 | [NSLayoutConstraint constraintWithItem:control 194 | attribute:NSLayoutAttributeWidth 195 | relatedBy:NSLayoutRelationEqual 196 | toItem:self 197 | attribute:NSLayoutAttributeWidth 198 | multiplier:1 199 | constant:0]; 200 | 201 | [self addConstraints:@[ 202 | leftConstraint, 203 | topConstraint, 204 | rightConstraint, 205 | heightConstraint, 206 | widthConstraint 207 | ]]; 208 | } 209 | 210 | @end 211 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControlDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 9740804C1C2E3958002AA364 /* BIInputMehodLoadingFooter.m in Sources */ = {isa = PBXBuildFile; fileRef = 974080401C2E3958002AA364 /* BIInputMehodLoadingFooter.m */; }; 11 | 9740804D1C2E3958002AA364 /* BIInputMethodRefreshHeader.m in Sources */ = {isa = PBXBuildFile; fileRef = 974080421C2E3958002AA364 /* BIInputMethodRefreshHeader.m */; }; 12 | 9740804E1C2E3958002AA364 /* BILoadingFooter.m in Sources */ = {isa = PBXBuildFile; fileRef = 974080441C2E3958002AA364 /* BILoadingFooter.m */; }; 13 | 9740804F1C2E3958002AA364 /* BIRefreshHeader.m in Sources */ = {isa = PBXBuildFile; fileRef = 974080471C2E3958002AA364 /* BIRefreshHeader.m */; }; 14 | 974080501C2E3958002AA364 /* UIScrollView+BICustomRefreshControl.m in Sources */ = {isa = PBXBuildFile; fileRef = 974080491C2E3958002AA364 /* UIScrollView+BICustomRefreshControl.m */; }; 15 | 974080511C2E3958002AA364 /* UIScrollView+BIRefreshControl.m in Sources */ = {isa = PBXBuildFile; fileRef = 9740804B1C2E3958002AA364 /* UIScrollView+BIRefreshControl.m */; }; 16 | 975592C11C30C83800B26461 /* NSString+Path.m in Sources */ = {isa = PBXBuildFile; fileRef = 975592C01C30C83800B26461 /* NSString+Path.m */; }; 17 | 9765E43E1C04418600120F3B /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 9765E43D1C04418600120F3B /* main.m */; }; 18 | 9765E4411C04418700120F3B /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 9765E4401C04418700120F3B /* AppDelegate.m */; }; 19 | 9765E4441C04418700120F3B /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9765E4431C04418700120F3B /* ViewController.m */; }; 20 | 9765E4471C04418700120F3B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9765E4451C04418700120F3B /* Main.storyboard */; }; 21 | 9765E4491C04418700120F3B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9765E4481C04418700120F3B /* Assets.xcassets */; }; 22 | 9765E44C1C04418700120F3B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9765E44A1C04418700120F3B /* LaunchScreen.storyboard */; }; 23 | 9765E4571C04418700120F3B /* BIRefreshControlDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 9765E4561C04418700120F3B /* BIRefreshControlDemoTests.m */; }; 24 | 9765E4621C04418700120F3B /* BIRefreshControlDemoUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 9765E4611C04418700120F3B /* BIRefreshControlDemoUITests.m */; }; 25 | /* End PBXBuildFile section */ 26 | 27 | /* Begin PBXContainerItemProxy section */ 28 | 9765E4531C04418700120F3B /* PBXContainerItemProxy */ = { 29 | isa = PBXContainerItemProxy; 30 | containerPortal = 9765E4311C04418600120F3B /* Project object */; 31 | proxyType = 1; 32 | remoteGlobalIDString = 9765E4381C04418600120F3B; 33 | remoteInfo = BIRefreshControlDemo; 34 | }; 35 | 9765E45E1C04418700120F3B /* PBXContainerItemProxy */ = { 36 | isa = PBXContainerItemProxy; 37 | containerPortal = 9765E4311C04418600120F3B /* Project object */; 38 | proxyType = 1; 39 | remoteGlobalIDString = 9765E4381C04418600120F3B; 40 | remoteInfo = BIRefreshControlDemo; 41 | }; 42 | /* End PBXContainerItemProxy section */ 43 | 44 | /* Begin PBXFileReference section */ 45 | 9740803F1C2E3958002AA364 /* BIInputMehodLoadingFooter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BIInputMehodLoadingFooter.h; sourceTree = ""; }; 46 | 974080401C2E3958002AA364 /* BIInputMehodLoadingFooter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BIInputMehodLoadingFooter.m; sourceTree = ""; }; 47 | 974080411C2E3958002AA364 /* BIInputMethodRefreshHeader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BIInputMethodRefreshHeader.h; sourceTree = ""; }; 48 | 974080421C2E3958002AA364 /* BIInputMethodRefreshHeader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BIInputMethodRefreshHeader.m; sourceTree = ""; }; 49 | 974080431C2E3958002AA364 /* BILoadingFooter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BILoadingFooter.h; sourceTree = ""; }; 50 | 974080441C2E3958002AA364 /* BILoadingFooter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BILoadingFooter.m; sourceTree = ""; }; 51 | 974080451C2E3958002AA364 /* BIRefresh.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BIRefresh.h; sourceTree = ""; }; 52 | 974080461C2E3958002AA364 /* BIRefreshHeader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BIRefreshHeader.h; sourceTree = ""; }; 53 | 974080471C2E3958002AA364 /* BIRefreshHeader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BIRefreshHeader.m; sourceTree = ""; }; 54 | 974080481C2E3958002AA364 /* UIScrollView+BICustomRefreshControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIScrollView+BICustomRefreshControl.h"; sourceTree = ""; }; 55 | 974080491C2E3958002AA364 /* UIScrollView+BICustomRefreshControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIScrollView+BICustomRefreshControl.m"; sourceTree = ""; }; 56 | 9740804A1C2E3958002AA364 /* UIScrollView+BIRefreshControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIScrollView+BIRefreshControl.h"; sourceTree = ""; }; 57 | 9740804B1C2E3958002AA364 /* UIScrollView+BIRefreshControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIScrollView+BIRefreshControl.m"; sourceTree = ""; }; 58 | 975592BF1C30C83800B26461 /* NSString+Path.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+Path.h"; sourceTree = ""; }; 59 | 975592C01C30C83800B26461 /* NSString+Path.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+Path.m"; sourceTree = ""; }; 60 | 9765E4391C04418600120F3B /* BIRefreshControlDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BIRefreshControlDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 61 | 9765E43D1C04418600120F3B /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 62 | 9765E43F1C04418700120F3B /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = AppDelegate.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 63 | 9765E4401C04418700120F3B /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = AppDelegate.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 64 | 9765E4421C04418700120F3B /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 65 | 9765E4431C04418700120F3B /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 66 | 9765E4461C04418700120F3B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 67 | 9765E4481C04418700120F3B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 68 | 9765E44B1C04418700120F3B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 69 | 9765E44D1C04418700120F3B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 70 | 9765E4521C04418700120F3B /* BIRefreshControlDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = BIRefreshControlDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 71 | 9765E4561C04418700120F3B /* BIRefreshControlDemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = BIRefreshControlDemoTests.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 72 | 9765E4581C04418700120F3B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 73 | 9765E45D1C04418700120F3B /* BIRefreshControlDemoUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = BIRefreshControlDemoUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 74 | 9765E4611C04418700120F3B /* BIRefreshControlDemoUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = BIRefreshControlDemoUITests.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 75 | 9765E4631C04418700120F3B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 76 | /* End PBXFileReference section */ 77 | 78 | /* Begin PBXFrameworksBuildPhase section */ 79 | 9765E4361C04418600120F3B /* Frameworks */ = { 80 | isa = PBXFrameworksBuildPhase; 81 | buildActionMask = 2147483647; 82 | files = ( 83 | ); 84 | runOnlyForDeploymentPostprocessing = 0; 85 | }; 86 | 9765E44F1C04418700120F3B /* Frameworks */ = { 87 | isa = PBXFrameworksBuildPhase; 88 | buildActionMask = 2147483647; 89 | files = ( 90 | ); 91 | runOnlyForDeploymentPostprocessing = 0; 92 | }; 93 | 9765E45A1C04418700120F3B /* Frameworks */ = { 94 | isa = PBXFrameworksBuildPhase; 95 | buildActionMask = 2147483647; 96 | files = ( 97 | ); 98 | runOnlyForDeploymentPostprocessing = 0; 99 | }; 100 | /* End PBXFrameworksBuildPhase section */ 101 | 102 | /* Begin PBXGroup section */ 103 | 9740803E1C2E3958002AA364 /* BIRefreshControl */ = { 104 | isa = PBXGroup; 105 | children = ( 106 | 974080451C2E3958002AA364 /* BIRefresh.h */, 107 | 975592BE1C30C80700B26461 /* Custom */, 108 | 975592BD1C30C7CF00B26461 /* Classes */, 109 | ); 110 | path = BIRefreshControl; 111 | sourceTree = SOURCE_ROOT; 112 | }; 113 | 975592BD1C30C7CF00B26461 /* Classes */ = { 114 | isa = PBXGroup; 115 | children = ( 116 | 9740804A1C2E3958002AA364 /* UIScrollView+BIRefreshControl.h */, 117 | 9740804B1C2E3958002AA364 /* UIScrollView+BIRefreshControl.m */, 118 | 974080431C2E3958002AA364 /* BILoadingFooter.h */, 119 | 974080441C2E3958002AA364 /* BILoadingFooter.m */, 120 | 974080461C2E3958002AA364 /* BIRefreshHeader.h */, 121 | 974080471C2E3958002AA364 /* BIRefreshHeader.m */, 122 | ); 123 | name = Classes; 124 | sourceTree = ""; 125 | }; 126 | 975592BE1C30C80700B26461 /* Custom */ = { 127 | isa = PBXGroup; 128 | children = ( 129 | 975592BF1C30C83800B26461 /* NSString+Path.h */, 130 | 975592C01C30C83800B26461 /* NSString+Path.m */, 131 | 9740803F1C2E3958002AA364 /* BIInputMehodLoadingFooter.h */, 132 | 974080401C2E3958002AA364 /* BIInputMehodLoadingFooter.m */, 133 | 974080411C2E3958002AA364 /* BIInputMethodRefreshHeader.h */, 134 | 974080421C2E3958002AA364 /* BIInputMethodRefreshHeader.m */, 135 | 974080481C2E3958002AA364 /* UIScrollView+BICustomRefreshControl.h */, 136 | 974080491C2E3958002AA364 /* UIScrollView+BICustomRefreshControl.m */, 137 | ); 138 | name = Custom; 139 | sourceTree = ""; 140 | }; 141 | 9765E4301C04418600120F3B = { 142 | isa = PBXGroup; 143 | children = ( 144 | 9765E43B1C04418600120F3B /* BIRefreshControlDemo */, 145 | 9765E4551C04418700120F3B /* BIRefreshControlDemoTests */, 146 | 9765E4601C04418700120F3B /* BIRefreshControlDemoUITests */, 147 | 9765E43A1C04418600120F3B /* Products */, 148 | ); 149 | sourceTree = ""; 150 | }; 151 | 9765E43A1C04418600120F3B /* Products */ = { 152 | isa = PBXGroup; 153 | children = ( 154 | 9765E4391C04418600120F3B /* BIRefreshControlDemo.app */, 155 | 9765E4521C04418700120F3B /* BIRefreshControlDemoTests.xctest */, 156 | 9765E45D1C04418700120F3B /* BIRefreshControlDemoUITests.xctest */, 157 | ); 158 | name = Products; 159 | sourceTree = ""; 160 | }; 161 | 9765E43B1C04418600120F3B /* BIRefreshControlDemo */ = { 162 | isa = PBXGroup; 163 | children = ( 164 | 9740803E1C2E3958002AA364 /* BIRefreshControl */, 165 | 9765E43F1C04418700120F3B /* AppDelegate.h */, 166 | 9765E4401C04418700120F3B /* AppDelegate.m */, 167 | 9765E4421C04418700120F3B /* ViewController.h */, 168 | 9765E4431C04418700120F3B /* ViewController.m */, 169 | 9765E4451C04418700120F3B /* Main.storyboard */, 170 | 9765E4481C04418700120F3B /* Assets.xcassets */, 171 | 9765E44A1C04418700120F3B /* LaunchScreen.storyboard */, 172 | 9765E44D1C04418700120F3B /* Info.plist */, 173 | 9765E43C1C04418600120F3B /* Supporting Files */, 174 | ); 175 | path = BIRefreshControlDemo; 176 | sourceTree = ""; 177 | }; 178 | 9765E43C1C04418600120F3B /* Supporting Files */ = { 179 | isa = PBXGroup; 180 | children = ( 181 | 9765E43D1C04418600120F3B /* main.m */, 182 | ); 183 | name = "Supporting Files"; 184 | sourceTree = ""; 185 | }; 186 | 9765E4551C04418700120F3B /* BIRefreshControlDemoTests */ = { 187 | isa = PBXGroup; 188 | children = ( 189 | 9765E4561C04418700120F3B /* BIRefreshControlDemoTests.m */, 190 | 9765E4581C04418700120F3B /* Info.plist */, 191 | ); 192 | path = BIRefreshControlDemoTests; 193 | sourceTree = ""; 194 | }; 195 | 9765E4601C04418700120F3B /* BIRefreshControlDemoUITests */ = { 196 | isa = PBXGroup; 197 | children = ( 198 | 9765E4611C04418700120F3B /* BIRefreshControlDemoUITests.m */, 199 | 9765E4631C04418700120F3B /* Info.plist */, 200 | ); 201 | path = BIRefreshControlDemoUITests; 202 | sourceTree = ""; 203 | }; 204 | /* End PBXGroup section */ 205 | 206 | /* Begin PBXNativeTarget section */ 207 | 9765E4381C04418600120F3B /* BIRefreshControlDemo */ = { 208 | isa = PBXNativeTarget; 209 | buildConfigurationList = 9765E4661C04418700120F3B /* Build configuration list for PBXNativeTarget "BIRefreshControlDemo" */; 210 | buildPhases = ( 211 | 9765E4351C04418600120F3B /* Sources */, 212 | 9765E4361C04418600120F3B /* Frameworks */, 213 | 9765E4371C04418600120F3B /* Resources */, 214 | ); 215 | buildRules = ( 216 | ); 217 | dependencies = ( 218 | ); 219 | name = BIRefreshControlDemo; 220 | productName = BIRefreshControlDemo; 221 | productReference = 9765E4391C04418600120F3B /* BIRefreshControlDemo.app */; 222 | productType = "com.apple.product-type.application"; 223 | }; 224 | 9765E4511C04418700120F3B /* BIRefreshControlDemoTests */ = { 225 | isa = PBXNativeTarget; 226 | buildConfigurationList = 9765E4691C04418700120F3B /* Build configuration list for PBXNativeTarget "BIRefreshControlDemoTests" */; 227 | buildPhases = ( 228 | 9765E44E1C04418700120F3B /* Sources */, 229 | 9765E44F1C04418700120F3B /* Frameworks */, 230 | 9765E4501C04418700120F3B /* Resources */, 231 | ); 232 | buildRules = ( 233 | ); 234 | dependencies = ( 235 | 9765E4541C04418700120F3B /* PBXTargetDependency */, 236 | ); 237 | name = BIRefreshControlDemoTests; 238 | productName = BIRefreshControlDemoTests; 239 | productReference = 9765E4521C04418700120F3B /* BIRefreshControlDemoTests.xctest */; 240 | productType = "com.apple.product-type.bundle.unit-test"; 241 | }; 242 | 9765E45C1C04418700120F3B /* BIRefreshControlDemoUITests */ = { 243 | isa = PBXNativeTarget; 244 | buildConfigurationList = 9765E46C1C04418700120F3B /* Build configuration list for PBXNativeTarget "BIRefreshControlDemoUITests" */; 245 | buildPhases = ( 246 | 9765E4591C04418700120F3B /* Sources */, 247 | 9765E45A1C04418700120F3B /* Frameworks */, 248 | 9765E45B1C04418700120F3B /* Resources */, 249 | ); 250 | buildRules = ( 251 | ); 252 | dependencies = ( 253 | 9765E45F1C04418700120F3B /* PBXTargetDependency */, 254 | ); 255 | name = BIRefreshControlDemoUITests; 256 | productName = BIRefreshControlDemoUITests; 257 | productReference = 9765E45D1C04418700120F3B /* BIRefreshControlDemoUITests.xctest */; 258 | productType = "com.apple.product-type.bundle.ui-testing"; 259 | }; 260 | /* End PBXNativeTarget section */ 261 | 262 | /* Begin PBXProject section */ 263 | 9765E4311C04418600120F3B /* Project object */ = { 264 | isa = PBXProject; 265 | attributes = { 266 | LastUpgradeCheck = 0710; 267 | ORGANIZATIONNAME = AugustRush; 268 | TargetAttributes = { 269 | 9765E4381C04418600120F3B = { 270 | CreatedOnToolsVersion = 7.1.1; 271 | }; 272 | 9765E4511C04418700120F3B = { 273 | CreatedOnToolsVersion = 7.1.1; 274 | TestTargetID = 9765E4381C04418600120F3B; 275 | }; 276 | 9765E45C1C04418700120F3B = { 277 | CreatedOnToolsVersion = 7.1.1; 278 | TestTargetID = 9765E4381C04418600120F3B; 279 | }; 280 | }; 281 | }; 282 | buildConfigurationList = 9765E4341C04418600120F3B /* Build configuration list for PBXProject "BIRefreshControlDemo" */; 283 | compatibilityVersion = "Xcode 3.2"; 284 | developmentRegion = English; 285 | hasScannedForEncodings = 0; 286 | knownRegions = ( 287 | en, 288 | Base, 289 | ); 290 | mainGroup = 9765E4301C04418600120F3B; 291 | productRefGroup = 9765E43A1C04418600120F3B /* Products */; 292 | projectDirPath = ""; 293 | projectRoot = ""; 294 | targets = ( 295 | 9765E4381C04418600120F3B /* BIRefreshControlDemo */, 296 | 9765E4511C04418700120F3B /* BIRefreshControlDemoTests */, 297 | 9765E45C1C04418700120F3B /* BIRefreshControlDemoUITests */, 298 | ); 299 | }; 300 | /* End PBXProject section */ 301 | 302 | /* Begin PBXResourcesBuildPhase section */ 303 | 9765E4371C04418600120F3B /* Resources */ = { 304 | isa = PBXResourcesBuildPhase; 305 | buildActionMask = 2147483647; 306 | files = ( 307 | 9765E44C1C04418700120F3B /* LaunchScreen.storyboard in Resources */, 308 | 9765E4491C04418700120F3B /* Assets.xcassets in Resources */, 309 | 9765E4471C04418700120F3B /* Main.storyboard in Resources */, 310 | ); 311 | runOnlyForDeploymentPostprocessing = 0; 312 | }; 313 | 9765E4501C04418700120F3B /* Resources */ = { 314 | isa = PBXResourcesBuildPhase; 315 | buildActionMask = 2147483647; 316 | files = ( 317 | ); 318 | runOnlyForDeploymentPostprocessing = 0; 319 | }; 320 | 9765E45B1C04418700120F3B /* Resources */ = { 321 | isa = PBXResourcesBuildPhase; 322 | buildActionMask = 2147483647; 323 | files = ( 324 | ); 325 | runOnlyForDeploymentPostprocessing = 0; 326 | }; 327 | /* End PBXResourcesBuildPhase section */ 328 | 329 | /* Begin PBXSourcesBuildPhase section */ 330 | 9765E4351C04418600120F3B /* Sources */ = { 331 | isa = PBXSourcesBuildPhase; 332 | buildActionMask = 2147483647; 333 | files = ( 334 | 9765E4441C04418700120F3B /* ViewController.m in Sources */, 335 | 974080501C2E3958002AA364 /* UIScrollView+BICustomRefreshControl.m in Sources */, 336 | 9740804F1C2E3958002AA364 /* BIRefreshHeader.m in Sources */, 337 | 9740804D1C2E3958002AA364 /* BIInputMethodRefreshHeader.m in Sources */, 338 | 975592C11C30C83800B26461 /* NSString+Path.m in Sources */, 339 | 9765E4411C04418700120F3B /* AppDelegate.m in Sources */, 340 | 9765E43E1C04418600120F3B /* main.m in Sources */, 341 | 9740804E1C2E3958002AA364 /* BILoadingFooter.m in Sources */, 342 | 9740804C1C2E3958002AA364 /* BIInputMehodLoadingFooter.m in Sources */, 343 | 974080511C2E3958002AA364 /* UIScrollView+BIRefreshControl.m in Sources */, 344 | ); 345 | runOnlyForDeploymentPostprocessing = 0; 346 | }; 347 | 9765E44E1C04418700120F3B /* Sources */ = { 348 | isa = PBXSourcesBuildPhase; 349 | buildActionMask = 2147483647; 350 | files = ( 351 | 9765E4571C04418700120F3B /* BIRefreshControlDemoTests.m in Sources */, 352 | ); 353 | runOnlyForDeploymentPostprocessing = 0; 354 | }; 355 | 9765E4591C04418700120F3B /* Sources */ = { 356 | isa = PBXSourcesBuildPhase; 357 | buildActionMask = 2147483647; 358 | files = ( 359 | 9765E4621C04418700120F3B /* BIRefreshControlDemoUITests.m in Sources */, 360 | ); 361 | runOnlyForDeploymentPostprocessing = 0; 362 | }; 363 | /* End PBXSourcesBuildPhase section */ 364 | 365 | /* Begin PBXTargetDependency section */ 366 | 9765E4541C04418700120F3B /* PBXTargetDependency */ = { 367 | isa = PBXTargetDependency; 368 | target = 9765E4381C04418600120F3B /* BIRefreshControlDemo */; 369 | targetProxy = 9765E4531C04418700120F3B /* PBXContainerItemProxy */; 370 | }; 371 | 9765E45F1C04418700120F3B /* PBXTargetDependency */ = { 372 | isa = PBXTargetDependency; 373 | target = 9765E4381C04418600120F3B /* BIRefreshControlDemo */; 374 | targetProxy = 9765E45E1C04418700120F3B /* PBXContainerItemProxy */; 375 | }; 376 | /* End PBXTargetDependency section */ 377 | 378 | /* Begin PBXVariantGroup section */ 379 | 9765E4451C04418700120F3B /* Main.storyboard */ = { 380 | isa = PBXVariantGroup; 381 | children = ( 382 | 9765E4461C04418700120F3B /* Base */, 383 | ); 384 | name = Main.storyboard; 385 | sourceTree = ""; 386 | }; 387 | 9765E44A1C04418700120F3B /* LaunchScreen.storyboard */ = { 388 | isa = PBXVariantGroup; 389 | children = ( 390 | 9765E44B1C04418700120F3B /* Base */, 391 | ); 392 | name = LaunchScreen.storyboard; 393 | sourceTree = ""; 394 | }; 395 | /* End PBXVariantGroup section */ 396 | 397 | /* Begin XCBuildConfiguration section */ 398 | 9765E4641C04418700120F3B /* Debug */ = { 399 | isa = XCBuildConfiguration; 400 | buildSettings = { 401 | ALWAYS_SEARCH_USER_PATHS = NO; 402 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 403 | CLANG_CXX_LIBRARY = "libc++"; 404 | CLANG_ENABLE_MODULES = YES; 405 | CLANG_ENABLE_OBJC_ARC = YES; 406 | CLANG_WARN_BOOL_CONVERSION = YES; 407 | CLANG_WARN_CONSTANT_CONVERSION = YES; 408 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 409 | CLANG_WARN_EMPTY_BODY = YES; 410 | CLANG_WARN_ENUM_CONVERSION = YES; 411 | CLANG_WARN_INT_CONVERSION = YES; 412 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 413 | CLANG_WARN_UNREACHABLE_CODE = YES; 414 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 415 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 416 | COPY_PHASE_STRIP = NO; 417 | DEBUG_INFORMATION_FORMAT = dwarf; 418 | ENABLE_STRICT_OBJC_MSGSEND = YES; 419 | ENABLE_TESTABILITY = YES; 420 | GCC_C_LANGUAGE_STANDARD = gnu99; 421 | GCC_DYNAMIC_NO_PIC = NO; 422 | GCC_NO_COMMON_BLOCKS = YES; 423 | GCC_OPTIMIZATION_LEVEL = 0; 424 | GCC_PREPROCESSOR_DEFINITIONS = ( 425 | "DEBUG=1", 426 | "$(inherited)", 427 | ); 428 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 429 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 430 | GCC_WARN_UNDECLARED_SELECTOR = YES; 431 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 432 | GCC_WARN_UNUSED_FUNCTION = YES; 433 | GCC_WARN_UNUSED_VARIABLE = YES; 434 | IPHONEOS_DEPLOYMENT_TARGET = 9.1; 435 | MTL_ENABLE_DEBUG_INFO = YES; 436 | ONLY_ACTIVE_ARCH = YES; 437 | SDKROOT = iphoneos; 438 | TARGETED_DEVICE_FAMILY = "1,2"; 439 | }; 440 | name = Debug; 441 | }; 442 | 9765E4651C04418700120F3B /* Release */ = { 443 | isa = XCBuildConfiguration; 444 | buildSettings = { 445 | ALWAYS_SEARCH_USER_PATHS = NO; 446 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 447 | CLANG_CXX_LIBRARY = "libc++"; 448 | CLANG_ENABLE_MODULES = YES; 449 | CLANG_ENABLE_OBJC_ARC = YES; 450 | CLANG_WARN_BOOL_CONVERSION = YES; 451 | CLANG_WARN_CONSTANT_CONVERSION = YES; 452 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 453 | CLANG_WARN_EMPTY_BODY = YES; 454 | CLANG_WARN_ENUM_CONVERSION = YES; 455 | CLANG_WARN_INT_CONVERSION = YES; 456 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 457 | CLANG_WARN_UNREACHABLE_CODE = YES; 458 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 459 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 460 | COPY_PHASE_STRIP = NO; 461 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 462 | ENABLE_NS_ASSERTIONS = NO; 463 | ENABLE_STRICT_OBJC_MSGSEND = YES; 464 | GCC_C_LANGUAGE_STANDARD = gnu99; 465 | GCC_NO_COMMON_BLOCKS = YES; 466 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 467 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 468 | GCC_WARN_UNDECLARED_SELECTOR = YES; 469 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 470 | GCC_WARN_UNUSED_FUNCTION = YES; 471 | GCC_WARN_UNUSED_VARIABLE = YES; 472 | IPHONEOS_DEPLOYMENT_TARGET = 9.1; 473 | MTL_ENABLE_DEBUG_INFO = NO; 474 | SDKROOT = iphoneos; 475 | TARGETED_DEVICE_FAMILY = "1,2"; 476 | VALIDATE_PRODUCT = YES; 477 | }; 478 | name = Release; 479 | }; 480 | 9765E4671C04418700120F3B /* Debug */ = { 481 | isa = XCBuildConfiguration; 482 | buildSettings = { 483 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 484 | INFOPLIST_FILE = BIRefreshControlDemo/Info.plist; 485 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 486 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 487 | PRODUCT_BUNDLE_IDENTIFIER = AR.BIRefreshControlDemo; 488 | PRODUCT_NAME = "$(TARGET_NAME)"; 489 | }; 490 | name = Debug; 491 | }; 492 | 9765E4681C04418700120F3B /* Release */ = { 493 | isa = XCBuildConfiguration; 494 | buildSettings = { 495 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 496 | INFOPLIST_FILE = BIRefreshControlDemo/Info.plist; 497 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 498 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 499 | PRODUCT_BUNDLE_IDENTIFIER = AR.BIRefreshControlDemo; 500 | PRODUCT_NAME = "$(TARGET_NAME)"; 501 | }; 502 | name = Release; 503 | }; 504 | 9765E46A1C04418700120F3B /* Debug */ = { 505 | isa = XCBuildConfiguration; 506 | buildSettings = { 507 | BUNDLE_LOADER = "$(TEST_HOST)"; 508 | INFOPLIST_FILE = BIRefreshControlDemoTests/Info.plist; 509 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 510 | PRODUCT_BUNDLE_IDENTIFIER = AR.BIRefreshControlDemoTests; 511 | PRODUCT_NAME = "$(TARGET_NAME)"; 512 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/BIRefreshControlDemo.app/BIRefreshControlDemo"; 513 | }; 514 | name = Debug; 515 | }; 516 | 9765E46B1C04418700120F3B /* Release */ = { 517 | isa = XCBuildConfiguration; 518 | buildSettings = { 519 | BUNDLE_LOADER = "$(TEST_HOST)"; 520 | INFOPLIST_FILE = BIRefreshControlDemoTests/Info.plist; 521 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 522 | PRODUCT_BUNDLE_IDENTIFIER = AR.BIRefreshControlDemoTests; 523 | PRODUCT_NAME = "$(TARGET_NAME)"; 524 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/BIRefreshControlDemo.app/BIRefreshControlDemo"; 525 | }; 526 | name = Release; 527 | }; 528 | 9765E46D1C04418700120F3B /* Debug */ = { 529 | isa = XCBuildConfiguration; 530 | buildSettings = { 531 | INFOPLIST_FILE = BIRefreshControlDemoUITests/Info.plist; 532 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 533 | PRODUCT_BUNDLE_IDENTIFIER = AR.BIRefreshControlDemoUITests; 534 | PRODUCT_NAME = "$(TARGET_NAME)"; 535 | TEST_TARGET_NAME = BIRefreshControlDemo; 536 | USES_XCTRUNNER = YES; 537 | }; 538 | name = Debug; 539 | }; 540 | 9765E46E1C04418700120F3B /* Release */ = { 541 | isa = XCBuildConfiguration; 542 | buildSettings = { 543 | INFOPLIST_FILE = BIRefreshControlDemoUITests/Info.plist; 544 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 545 | PRODUCT_BUNDLE_IDENTIFIER = AR.BIRefreshControlDemoUITests; 546 | PRODUCT_NAME = "$(TARGET_NAME)"; 547 | TEST_TARGET_NAME = BIRefreshControlDemo; 548 | USES_XCTRUNNER = YES; 549 | }; 550 | name = Release; 551 | }; 552 | /* End XCBuildConfiguration section */ 553 | 554 | /* Begin XCConfigurationList section */ 555 | 9765E4341C04418600120F3B /* Build configuration list for PBXProject "BIRefreshControlDemo" */ = { 556 | isa = XCConfigurationList; 557 | buildConfigurations = ( 558 | 9765E4641C04418700120F3B /* Debug */, 559 | 9765E4651C04418700120F3B /* Release */, 560 | ); 561 | defaultConfigurationIsVisible = 0; 562 | defaultConfigurationName = Release; 563 | }; 564 | 9765E4661C04418700120F3B /* Build configuration list for PBXNativeTarget "BIRefreshControlDemo" */ = { 565 | isa = XCConfigurationList; 566 | buildConfigurations = ( 567 | 9765E4671C04418700120F3B /* Debug */, 568 | 9765E4681C04418700120F3B /* Release */, 569 | ); 570 | defaultConfigurationIsVisible = 0; 571 | defaultConfigurationName = Release; 572 | }; 573 | 9765E4691C04418700120F3B /* Build configuration list for PBXNativeTarget "BIRefreshControlDemoTests" */ = { 574 | isa = XCConfigurationList; 575 | buildConfigurations = ( 576 | 9765E46A1C04418700120F3B /* Debug */, 577 | 9765E46B1C04418700120F3B /* Release */, 578 | ); 579 | defaultConfigurationIsVisible = 0; 580 | defaultConfigurationName = Release; 581 | }; 582 | 9765E46C1C04418700120F3B /* Build configuration list for PBXNativeTarget "BIRefreshControlDemoUITests" */ = { 583 | isa = XCConfigurationList; 584 | buildConfigurations = ( 585 | 9765E46D1C04418700120F3B /* Debug */, 586 | 9765E46E1C04418700120F3B /* Release */, 587 | ); 588 | defaultConfigurationIsVisible = 0; 589 | defaultConfigurationName = Release; 590 | }; 591 | /* End XCConfigurationList section */ 592 | }; 593 | rootObject = 9765E4311C04418600120F3B /* Project object */; 594 | } 595 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControlDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControlDemo.xcodeproj/project.xcworkspace/xcuserdata/August.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AugustRush/BIRefreshControl/7cfc352aee9449d2e4a3487030081cd18a25ddfc/BIRefreshControlDemo/BIRefreshControlDemo.xcodeproj/project.xcworkspace/xcuserdata/August.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControlDemo.xcodeproj/xcuserdata/August.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControlDemo.xcodeproj/xcuserdata/August.xcuserdatad/xcschemes/BIRefreshControlDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 43 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 74 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 95 | 101 | 102 | 103 | 104 | 106 | 107 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControlDemo.xcodeproj/xcuserdata/August.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | BIRefreshControlDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 9765E4381C04418600120F3B 16 | 17 | primary 18 | 19 | 20 | 9765E4511C04418700120F3B 21 | 22 | primary 23 | 24 | 25 | 9765E45C1C04418700120F3B 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControlDemo/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AugustRush/BIRefreshControl/7cfc352aee9449d2e4a3487030081cd18a25ddfc/BIRefreshControlDemo/BIRefreshControlDemo/.DS_Store -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControlDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // BIRefreshHeaderDemo 4 | // 5 | // Created by AugustRush on 11/24/15. 6 | // Copyright © 2015 AugustRush. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControlDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // BIRefreshHeaderDemo 4 | // 5 | // Created by AugustRush on 11/24/15. 6 | // Copyright © 2015 AugustRush. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControlDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControlDemo/BIInputMehodLoadingFooter.h: -------------------------------------------------------------------------------- 1 | // 2 | // BIInputMehodLoadingFooter.h 3 | // BIRefreshControlDemo 4 | // 5 | // Created by AugustRush on 11/25/15. 6 | // Copyright © 2015 AugustRush. All rights reserved. 7 | // 8 | 9 | #import "BILoadingFooter.h" 10 | 11 | @interface BIInputMehodLoadingFooter : BILoadingFooter 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControlDemo/BIInputMehodLoadingFooter.m: -------------------------------------------------------------------------------- 1 | // 2 | // BIInputMehodLoadingFooter.m 3 | // BIRefreshControlDemo 4 | // 5 | // Created by AugustRush on 11/25/15. 6 | // Copyright © 2015 AugustRush. All rights reserved. 7 | // 8 | 9 | #import "BIInputMehodLoadingFooter.h" 10 | 11 | @implementation BIInputMehodLoadingFooter 12 | 13 | - (instancetype)init { 14 | self = [super init]; 15 | if (self) { 16 | self.delegate = self; 17 | self.backgroundColor = [UIColor blackColor]; 18 | } 19 | return self; 20 | } 21 | 22 | #pragma mark - BILoadingFooterDelegate methods 23 | 24 | - (void)loadingFooter:(BILoadingFooter *)footer didChangedLoadingProgress:(CGFloat)progress { 25 | self.backgroundColor = [UIColor colorWithRed:progress green:progress blue:progress alpha:1]; 26 | } 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControlDemo/BIInputMethodRefreshHeader.h: -------------------------------------------------------------------------------- 1 | // 2 | // BIInputMethodRefreshHeader.h 3 | // BIRefreshHeaderDemo 4 | // 5 | // Created by AugustRush on 11/25/15. 6 | // Copyright © 2015 AugustRush. All rights reserved. 7 | // 8 | 9 | #import "BIRefreshHeader.h" 10 | 11 | @interface BIInputMethodRefreshHeader : BIRefreshHeader 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControlDemo/BIInputMethodRefreshHeader.m: -------------------------------------------------------------------------------- 1 | // 2 | // BIInputMethodRefreshHeader.m 3 | // BIRefreshHeaderDemo 4 | // 5 | // Created by AugustRush on 11/25/15. 6 | // Copyright © 2015 AugustRush. All rights reserved. 7 | // 8 | 9 | #import "BIInputMethodRefreshHeader.h" 10 | 11 | @implementation BIInputMethodRefreshHeader 12 | 13 | #pragma mark - init methods 14 | 15 | - (instancetype)init { 16 | self = [super init]; 17 | if (self) { 18 | self.delegate = self; 19 | self.backgroundColor = [UIColor redColor]; 20 | } 21 | return self; 22 | } 23 | 24 | #pragma mark - public methods 25 | 26 | #pragma mark - BIRefreshHeaderDelegate methods 27 | 28 | - (void)refreshControl:(BIRefreshHeader *)control didChangeRefreshProgress:(CGFloat)progress { 29 | NSLog(@"progress is %f",progress); 30 | self.alpha = progress; 31 | } 32 | 33 | - (void)refreshControl:(BIRefreshHeader *)control didChangeRefreshState:(BIRefreshHeaderState)state { 34 | switch (state) { 35 | case BIRefreshHeaderStateInitial: { 36 | 37 | break; 38 | } 39 | case BIRefreshHeaderStateRefreshing: { 40 | 41 | break; 42 | } 43 | case BIRefreshHeaderStateFinished: { 44 | 45 | break; 46 | } 47 | default: { 48 | break; 49 | } 50 | } 51 | } 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControlDemo/BILoadingFooter.h: -------------------------------------------------------------------------------- 1 | // 2 | // BILoadingControl.h 3 | // BIRefreshHeaderDemo 4 | // 5 | // Created by AugustRush on 11/25/15. 6 | // Copyright © 2015 AugustRush. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef NS_ENUM(NSUInteger, BILoadingFooterState) { 12 | BILoadingFooterStateInitial, 13 | BILoadingFooterStateLoading, 14 | BILoadingFooterStateFinished, 15 | }; 16 | 17 | @protocol BILoadingFooterDelegate; 18 | 19 | @interface BILoadingFooter : UIView 20 | 21 | @property (nonatomic, weak) id delegate; 22 | @property (nonatomic, assign) BILoadingFooterState state; 23 | @property (nonatomic, assign) CGFloat offsetThreshold; 24 | @property (nonatomic, copy) void (^loadingHandler)(void); 25 | 26 | - (void)startLoading; 27 | - (void)stopLoading; 28 | 29 | @end 30 | 31 | @protocol BILoadingFooterDelegate 32 | 33 | @optional 34 | - (void)loadingFooter:(BILoadingFooter *)footer didChangedLoadingProgress:(CGFloat)progress; 35 | - (void)loadingFooter:(BILoadingFooter *)footer didChangedLoadingState:(BILoadingFooterState)state; 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControlDemo/BILoadingFooter.m: -------------------------------------------------------------------------------- 1 | // 2 | // BILoadingControl.m 3 | // BIRefreshHeaderDemo 4 | // 5 | // Created by AugustRush on 11/25/15. 6 | // Copyright © 2015 AugustRush. All rights reserved. 7 | // 8 | 9 | #import "BILoadingFooter.h" 10 | #import "BIRefresh.h" 11 | #import "BIRefreshHeader.h" 12 | 13 | static void *BILoadingFooterObserverContentSizeContext = &BILoadingFooterObserverContentSizeContext; 14 | static void *BILoadingFooterObserverContentOffsetContext = &BILoadingFooterObserverContentOffsetContext; 15 | 16 | @interface BILoadingFooter () 17 | 18 | @property (nonatomic, weak) UIScrollView *scrollView; 19 | @property (nonatomic, assign) UIEdgeInsets origianlInset; 20 | @property (nonatomic, weak) NSLayoutConstraint *topConstraint; 21 | 22 | @end 23 | 24 | @implementation BILoadingFooter 25 | 26 | #pragma mark - init methods 27 | 28 | - (instancetype)init { 29 | self = [super init]; 30 | if (self) { 31 | self.state = BILoadingFooterStateInitial; 32 | } 33 | return self; 34 | } 35 | 36 | - (instancetype)initWithCoder:(NSCoder *)aDecoder { 37 | self = [super initWithCoder:aDecoder]; 38 | if (self) { 39 | self.state = BILoadingFooterStateInitial; 40 | } 41 | return self; 42 | } 43 | 44 | #pragma mark - override methods 45 | 46 | - (void)willMoveToSuperview:(UIView *)newSuperview { 47 | [super willMoveToSuperview:newSuperview]; 48 | 49 | if (self.superview) { 50 | [self removeLoadingControlObservers]; 51 | } 52 | 53 | if (self.superview == nil && [newSuperview isKindOfClass:[UIScrollView class]]) { 54 | self.scrollView = (UIScrollView *)newSuperview; 55 | self.origianlInset = self.scrollView.contentInset; 56 | [self addRefreshControlObservers]; 57 | } 58 | } 59 | 60 | #pragma mark - private methods 61 | 62 | - (void)removeLoadingControlObservers { 63 | @try { 64 | [self.superview removeObserver:self forKeyPath:NSStringFromSelector(@selector(contentSize))]; 65 | [self.superview removeObserver:self forKeyPath:NSStringFromSelector(@selector(contentOffset))]; 66 | } 67 | @catch (NSException *exception) { 68 | } 69 | @finally { 70 | } 71 | } 72 | 73 | - (void)addRefreshControlObservers { 74 | [self.scrollView addObserver:self forKeyPath:NSStringFromSelector(@selector(contentSize)) options:NSKeyValueObservingOptionNew context:BILoadingFooterObserverContentSizeContext]; 75 | [self.scrollView addObserver:self forKeyPath:NSStringFromSelector(@selector(contentOffset)) options:NSKeyValueObservingOptionNew context:BILoadingFooterObserverContentOffsetContext]; 76 | } 77 | 78 | - (void)springAnimation:(void(^)(void))animation completion:(void(^)(BOOL finished))completion { 79 | [UIView animateWithDuration:kBIRefreshHeaderAnimateInterval 80 | delay:0.0 81 | usingSpringWithDamping:1.0 82 | initialSpringVelocity:0.2 83 | options:UIViewAnimationOptionCurveEaseOut 84 | animations:animation 85 | completion:completion]; 86 | 87 | } 88 | 89 | - (BOOL)canLoading { 90 | return self.scrollView.refreshHeader.state != BIRefreshHeaderStateRefreshing; 91 | } 92 | 93 | #pragma mark - NSKeyValueObserving method 94 | 95 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { 96 | if (context == BILoadingFooterObserverContentSizeContext) { 97 | CGSize newSize = [change[NSKeyValueChangeNewKey] CGSizeValue]; 98 | // 99 | self.topConstraint.constant = MAX(newSize.height + self.origianlInset.top, CGRectGetHeight(self.scrollView.bounds)); 100 | [self.scrollView bringSubviewToFront:self]; 101 | }else if (context == BILoadingFooterObserverContentOffsetContext) { 102 | CGPoint offset = [change[NSKeyValueChangeNewKey] CGPointValue]; 103 | CGFloat contentHeight = MAX(self.scrollView.contentSize.height, CGRectGetHeight(self.scrollView.bounds)); 104 | CGFloat progress = (offset.y + CGRectGetHeight(self.scrollView.bounds) - contentHeight)/self.offsetThreshold; 105 | if (offset.y > 0 && 106 | progress > 1 && 107 | self.scrollView.isTracking == NO) { 108 | [self startLoading]; 109 | } 110 | if (offset.y > 0 && 111 | [self.delegate respondsToSelector:@selector(loadingFooter:didChangedLoadingProgress:)]) { 112 | if (progress < 0) { 113 | progress = 0; 114 | } 115 | //if it's loading just make progress as 1 116 | [self.delegate loadingFooter:self didChangedLoadingProgress:(_state == BILoadingFooterStateLoading) ? 1:progress]; 117 | } 118 | } 119 | } 120 | 121 | #pragma mark - public methods 122 | 123 | - (void)startLoading { 124 | if (self.state != BILoadingFooterStateLoading && 125 | [self canLoading]) { 126 | self.state = BILoadingFooterStateLoading; 127 | self.scrollView.bounces = NO; 128 | //when contentSize.height < scrollView.bounds.size.height 129 | CGFloat height = CGRectGetHeight(self.scrollView.bounds) - self.origianlInset.top - self.origianlInset.bottom - self.scrollView.contentSize.height; 130 | if (height < 0) { 131 | height = 0; 132 | } 133 | [self springAnimation:^{ 134 | UIEdgeInsets inset = self.origianlInset; 135 | inset.bottom += (self.offsetThreshold + height); 136 | [self.scrollView setContentInset:inset]; 137 | } completion:^(BOOL finished) { 138 | self.scrollView.bounces = YES; 139 | if (self.loadingHandler) { 140 | self.loadingHandler(); 141 | } 142 | }]; 143 | } 144 | } 145 | 146 | - (void)stopLoading { 147 | if (self.state != BILoadingFooterStateFinished) { 148 | [self springAnimation:^{ 149 | [self.scrollView setContentInset:self.origianlInset]; 150 | } completion:^(BOOL finished) { 151 | self.state = BILoadingFooterStateFinished; 152 | }]; 153 | } 154 | } 155 | 156 | @end 157 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControlDemo/BIRefresh.h: -------------------------------------------------------------------------------- 1 | // 2 | // BIRefresh.h 3 | // BIRefreshControlDemo 4 | // 5 | // Created by AugustRush on 11/25/15. 6 | // Copyright © 2015 AugustRush. All rights reserved. 7 | // 8 | 9 | #ifndef BIRefresh_h 10 | #define BIRefresh_h 11 | 12 | #import "UIScrollView+BICustomRefreshControl.h" 13 | 14 | #define kBIRefreshHeaderAnimateInterval 0.5 15 | 16 | #endif /* BIRefresh_h */ 17 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControlDemo/BIRefreshHeader.h: -------------------------------------------------------------------------------- 1 | // 2 | // BIRefreshHeader.h 3 | // BIRefreshHeaderDemo 4 | // 5 | // Created by AugustRush on 11/24/15. 6 | // Copyright © 2015 AugustRush. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef NS_ENUM(NSUInteger, BIRefreshHeaderState) { 12 | BIRefreshHeaderStateInitial, 13 | BIRefreshHeaderStateRefreshing, 14 | BIRefreshHeaderStateFinished, 15 | }; 16 | 17 | @protocol BIRefreshHeaderDelegate; 18 | 19 | @interface BIRefreshHeader : UIView 20 | 21 | @property (nonatomic, weak) id delegate; 22 | @property (nonatomic, assign, readonly) BIRefreshHeaderState state; 23 | @property (nonatomic, assign) CGFloat offsetThreshold; 24 | @property (nonatomic, copy) void(^refreshHandler)(void); 25 | 26 | - (void)startRefreshing; 27 | - (void)stopRefreshing; 28 | 29 | @end 30 | 31 | @protocol BIRefreshHeaderDelegate 32 | 33 | @optional 34 | - (void)refreshControl:(BIRefreshHeader *)control didChangeRefreshProgress:(CGFloat)progress; 35 | - (void)refreshControl:(BIRefreshHeader *)control didChangeRefreshState:(BIRefreshHeaderState)state; 36 | 37 | @end -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControlDemo/BIRefreshHeader.m: -------------------------------------------------------------------------------- 1 | // 2 | // BIRefreshHeader.m 3 | // BIRefreshHeaderDemo 4 | // 5 | // Created by AugustRush on 11/24/15. 6 | // Copyright © 2015 AugustRush. All rights reserved. 7 | // 8 | 9 | #import "BIRefreshHeader.h" 10 | #import "BIRefresh.h" 11 | #import "BILoadingFooter.h" 12 | 13 | static void *BIRefreshHeaderObserverContentOffsetContext = &BIRefreshHeaderObserverContentOffsetContext; 14 | 15 | @interface BIRefreshHeader () 16 | 17 | @property (nonatomic, assign) BIRefreshHeaderState state; 18 | @property (nonatomic, weak) UIScrollView *scrollView; 19 | @property (nonatomic, assign) UIEdgeInsets originalInset; 20 | 21 | @end 22 | 23 | @implementation BIRefreshHeader 24 | 25 | #pragma mark - init methods 26 | 27 | - (instancetype)init { 28 | self = [super init]; 29 | if (self) { 30 | self.state = BIRefreshHeaderStateInitial; 31 | } 32 | return self; 33 | } 34 | 35 | - (instancetype)initWithCoder:(NSCoder *)aDecoder { 36 | self = [super initWithCoder:aDecoder]; 37 | if (self) { 38 | self.state = BIRefreshHeaderStateInitial; 39 | } 40 | return self; 41 | } 42 | 43 | #pragma mark - override methods 44 | 45 | - (void)willMoveToSuperview:(UIView *)newSuperview { 46 | [super willMoveToSuperview:newSuperview]; 47 | 48 | if (self.superview) { 49 | [self removeRefreshControlObservers]; 50 | } 51 | 52 | if (self.superview == nil && [newSuperview isKindOfClass:[UIScrollView class]]) { 53 | self.scrollView = (UIScrollView *)newSuperview; 54 | self.originalInset = self.scrollView.contentInset; 55 | [self addRefreshControlObservers]; 56 | } 57 | } 58 | 59 | #pragma mark - private methods 60 | 61 | - (void)addRefreshControlObservers { 62 | [self.scrollView addObserver:self forKeyPath:NSStringFromSelector(@selector(contentOffset)) options:NSKeyValueObservingOptionNew context:BIRefreshHeaderObserverContentOffsetContext]; 63 | } 64 | 65 | - (void)removeRefreshControlObservers { 66 | //must use superView to remove observers, why? 67 | @try { 68 | [self.superview removeObserver:self forKeyPath:NSStringFromSelector(@selector(contentOffset))]; 69 | } 70 | @catch (NSException *exception) { 71 | } 72 | @finally { 73 | } 74 | } 75 | 76 | - (void)springAnimation:(void(^)(void))animation completion:(void(^)(BOOL finished))completion { 77 | [UIView animateWithDuration:kBIRefreshHeaderAnimateInterval 78 | delay:0.0 79 | usingSpringWithDamping:1.0 80 | initialSpringVelocity:0.2 81 | options:UIViewAnimationOptionCurveEaseOut 82 | animations:animation 83 | completion:completion]; 84 | 85 | } 86 | 87 | - (void)setState:(BIRefreshHeaderState)state { 88 | _state = state; 89 | if ([self.delegate respondsToSelector:@selector(refreshControl:didChangeRefreshState:)]) { 90 | [self.delegate refreshControl:self didChangeRefreshState:_state]; 91 | } 92 | } 93 | 94 | - (BOOL)canRefresh { 95 | return self.scrollView.loadingFooter.state != BILoadingFooterStateLoading; 96 | } 97 | 98 | #pragma mark - NSKeyValueObserving methods 99 | 100 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { 101 | if (context == BIRefreshHeaderObserverContentOffsetContext) { 102 | CGPoint offset = [change[NSKeyValueChangeNewKey] CGPointValue]; 103 | CGFloat progress = -offset.y/self.offsetThreshold; 104 | if (progress > 1 && 105 | self.scrollView.isTracking == NO) { 106 | [self startRefreshing]; 107 | } 108 | if (offset.y < 0 && 109 | [self.delegate respondsToSelector:@selector(refreshControl:didChangeRefreshProgress:)]) { 110 | if (progress < 0) { 111 | progress = 0; 112 | } 113 | [self.delegate refreshControl:self didChangeRefreshProgress:(_state == BIRefreshHeaderStateRefreshing) ? 1:progress]; 114 | } 115 | } 116 | } 117 | 118 | #pragma mark - public methods 119 | 120 | - (void)stopRefreshing { 121 | if (self.state != BIRefreshHeaderStateFinished) { 122 | [self springAnimation:^{ 123 | [self.scrollView setContentInset:self.originalInset]; 124 | } completion:^(BOOL finished) { 125 | self.state = BIRefreshHeaderStateFinished; 126 | }]; 127 | } 128 | } 129 | 130 | - (void)startRefreshing { 131 | if (self.state != BIRefreshHeaderStateRefreshing && 132 | [self canRefresh]) { 133 | self.state = BIRefreshHeaderStateRefreshing; 134 | self.scrollView.bounces = NO; 135 | [self springAnimation:^{ 136 | [self.scrollView setContentInset:UIEdgeInsetsMake(_offsetThreshold, 0, 0, 0)]; 137 | self.scrollView.contentOffset = CGPointMake(0, -_offsetThreshold); 138 | } completion:^(BOOL finished) { 139 | self.scrollView.bounces = YES; 140 | if (self.refreshHandler) { 141 | self.refreshHandler(); 142 | } 143 | }]; 144 | } 145 | } 146 | 147 | @end 148 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControlDemo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControlDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControlDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControlDemo/UIScrollView+BICustomRefreshControl.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIScrollView+BICustomRefreshControl.h 3 | // BIRefreshHeaderDemo 4 | // 5 | // Created by AugustRush on 11/25/15. 6 | // Copyright © 2015 AugustRush. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "UIScrollView+BIRefreshControl.h" 11 | 12 | @interface UIScrollView (BICustomRefreshControl) 13 | 14 | - (void)bi_addInputMethodRefreshHeaderWithHandler:(void (^)(void))handler; 15 | - (void)bi_addInputMethodLoadingFooterWithHandler:(void (^)(void))handler; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControlDemo/UIScrollView+BICustomRefreshControl.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIScrollView+BICustomRefreshControl.m 3 | // BIRefreshHeaderDemo 4 | // 5 | // Created by AugustRush on 11/25/15. 6 | // Copyright © 2015 AugustRush. All rights reserved. 7 | // 8 | 9 | #import "UIScrollView+BICustomRefreshControl.h" 10 | #import "BIInputMethodRefreshHeader.h" 11 | #import "BIInputMehodLoadingFooter.h" 12 | 13 | @implementation UIScrollView (BICustomRefreshControl) 14 | 15 | - (void)bi_addInputMethodRefreshHeaderWithHandler:(void (^)(void))handler { 16 | BIInputMethodRefreshHeader *header = [[BIInputMethodRefreshHeader alloc] init]; 17 | [self bi_addRefreshHeaderWithControl:header Height:100 refreshHandler:handler]; 18 | } 19 | 20 | - (void)bi_addInputMethodLoadingFooterWithHandler:(void (^)(void))handler { 21 | BIInputMehodLoadingFooter *footer = [[BIInputMehodLoadingFooter alloc] init]; 22 | [self bi_addLoadingFooterWithControl:footer height:100 loadingHandler:handler]; 23 | } 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControlDemo/UIScrollView+BIRefreshControl.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIScrollView+BIRefreshHeader.h 3 | // BIRefreshHeaderDemo 4 | // 5 | // Created by AugustRush on 11/24/15. 6 | // Copyright © 2015 AugustRush. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "BIRefreshHeader.h" 11 | #import "BILoadingFooter.h" 12 | 13 | @interface UIScrollView (BIRefreshControl) 14 | 15 | @property (readonly) BIRefreshHeader *refreshHeader; 16 | @property (readonly) BILoadingFooter *loadingFooter; 17 | 18 | - (void)bi_addRefreshHeaderWithControl:(BIRefreshHeader *)control 19 | Height:(CGFloat)height 20 | refreshHandler:(void (^)(void))handler; 21 | 22 | - (void)bi_addLoadingFooterWithControl:(BILoadingFooter *)control 23 | height:(CGFloat)height 24 | loadingHandler:(void (^)(void))handler; 25 | 26 | //header 27 | - (void)bi_startRefreshing; 28 | - (void)bi_stopRefreshing; 29 | 30 | //footer 31 | - (void)bi_startLoading; 32 | - (void)bi_stopLoading; 33 | 34 | - (void)relayoutLoadingFooterWithHeight:(CGFloat)height; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControlDemo/UIScrollView+BIRefreshControl.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIScrollView+BIRefreshHeader.m 3 | // BIRefreshHeaderDemo 4 | // 5 | // Created by AugustRush on 11/24/15. 6 | // Copyright © 2015 AugustRush. All rights reserved. 7 | // 8 | 9 | #import "UIScrollView+BIRefreshControl.h" 10 | #import 11 | 12 | @interface UIScrollView (BIRefreshExtension) 13 | 14 | @end 15 | 16 | @implementation UIScrollView (BIRefreshExtension) 17 | 18 | - (void)setRefreshHeader:(BIRefreshHeader *)refreshHeader { 19 | objc_setAssociatedObject(self, @selector(refreshHeader), refreshHeader, 20 | OBJC_ASSOCIATION_ASSIGN); 21 | } 22 | 23 | - (BIRefreshHeader *)refreshHeader { 24 | return objc_getAssociatedObject(self, _cmd); 25 | } 26 | 27 | - (void)setLoadingFooter:(BILoadingFooter *)loadingFooter { 28 | objc_setAssociatedObject(self, @selector(loadingFooter), loadingFooter, 29 | OBJC_ASSOCIATION_ASSIGN); 30 | } 31 | 32 | - (BILoadingFooter *)loadingFooter { 33 | return objc_getAssociatedObject(self, _cmd); 34 | } 35 | 36 | @end 37 | 38 | @implementation UIScrollView (BIRefreshHeader) 39 | 40 | #pragma mark - public methods 41 | 42 | - (void)bi_addRefreshHeaderWithControl:(BIRefreshHeader *)control 43 | Height:(CGFloat)height 44 | refreshHandler:(void (^)(void))handler { 45 | control.refreshHandler = handler; 46 | control.offsetThreshold = height; 47 | [self addSubview:control]; 48 | // associate 49 | self.refreshHeader = control; 50 | // layout 51 | [self initializeLayoutWithRefreshControl:control height:height]; 52 | } 53 | 54 | - (void)bi_addLoadingFooterWithControl:(BILoadingFooter *)control 55 | height:(CGFloat)height 56 | loadingHandler:(void (^)(void))handler { 57 | control.loadingHandler = handler; 58 | control.offsetThreshold = height; 59 | [self addSubview:control]; 60 | 61 | // associate 62 | self.loadingFooter = control; 63 | // layout 64 | [self initializeLayoutWithLoadingControl:control height:height]; 65 | } 66 | 67 | - (void)bi_startRefreshing { 68 | [self.refreshHeader startRefreshing]; 69 | } 70 | 71 | - (void)bi_stopRefreshing { 72 | [self.refreshHeader stopRefreshing]; 73 | } 74 | 75 | - (void)bi_startLoading { 76 | [self.loadingFooter startLoading]; 77 | } 78 | 79 | - (void)bi_stopLoading { 80 | [self.loadingFooter stopLoading]; 81 | } 82 | 83 | #pragma mark - private methods 84 | 85 | - (void)initializeLayoutWithRefreshControl:(BIRefreshHeader *)control 86 | height:(CGFloat)height { 87 | control.translatesAutoresizingMaskIntoConstraints = NO; 88 | 89 | NSLayoutConstraint *leftConstraint = 90 | [NSLayoutConstraint constraintWithItem:control 91 | attribute:NSLayoutAttributeLeft 92 | relatedBy:NSLayoutRelationEqual 93 | toItem:self 94 | attribute:NSLayoutAttributeLeft 95 | multiplier:1 96 | constant:0]; 97 | 98 | NSLayoutConstraint *topConstraint = 99 | [NSLayoutConstraint constraintWithItem:control 100 | attribute:NSLayoutAttributeTop 101 | relatedBy:NSLayoutRelationEqual 102 | toItem:self 103 | attribute:NSLayoutAttributeTop 104 | multiplier:1 105 | constant:-height]; 106 | NSLayoutConstraint *rightConstraint = 107 | [NSLayoutConstraint constraintWithItem:control 108 | attribute:NSLayoutAttributeRight 109 | relatedBy:NSLayoutRelationEqual 110 | toItem:self 111 | attribute:NSLayoutAttributeRight 112 | multiplier:1 113 | constant:0]; 114 | NSLayoutConstraint *heightConstraint = 115 | [NSLayoutConstraint constraintWithItem:control 116 | attribute:NSLayoutAttributeHeight 117 | relatedBy:NSLayoutRelationEqual 118 | toItem:nil 119 | attribute:NSLayoutAttributeNotAnAttribute 120 | multiplier:1 121 | constant:height]; 122 | // must add width constraint for control,because scrollView's width up to its 123 | // subViews 124 | NSLayoutConstraint *widthConstraint = 125 | [NSLayoutConstraint constraintWithItem:control 126 | attribute:NSLayoutAttributeWidth 127 | relatedBy:NSLayoutRelationEqual 128 | toItem:self 129 | attribute:NSLayoutAttributeWidth 130 | multiplier:1 131 | constant:0]; 132 | 133 | [self addConstraints:@[ 134 | leftConstraint, 135 | topConstraint, 136 | rightConstraint, 137 | heightConstraint, 138 | widthConstraint 139 | ]]; 140 | } 141 | 142 | - (void)initializeLayoutWithLoadingControl:(BILoadingFooter *)control 143 | height:(CGFloat)height { 144 | control.translatesAutoresizingMaskIntoConstraints = NO; 145 | 146 | NSLayoutConstraint *leftConstraint = 147 | [NSLayoutConstraint constraintWithItem:control 148 | attribute:NSLayoutAttributeLeft 149 | relatedBy:NSLayoutRelationEqual 150 | toItem:self 151 | attribute:NSLayoutAttributeLeft 152 | multiplier:1 153 | constant:0]; 154 | 155 | NSLayoutConstraint *topConstraint = 156 | [NSLayoutConstraint constraintWithItem:control 157 | attribute:NSLayoutAttributeTop 158 | relatedBy:NSLayoutRelationEqual 159 | toItem:self 160 | attribute:NSLayoutAttributeTop 161 | multiplier:1 162 | constant:0]; 163 | [self.loadingFooter setValue:topConstraint forKey:@"topConstraint"];//assignment an private property 164 | NSLayoutConstraint *rightConstraint = 165 | [NSLayoutConstraint constraintWithItem:control 166 | attribute:NSLayoutAttributeRight 167 | relatedBy:NSLayoutRelationEqual 168 | toItem:self 169 | attribute:NSLayoutAttributeRight 170 | multiplier:1 171 | constant:0]; 172 | NSLayoutConstraint *heightConstraint = 173 | [NSLayoutConstraint constraintWithItem:control 174 | attribute:NSLayoutAttributeHeight 175 | relatedBy:NSLayoutRelationEqual 176 | toItem:nil 177 | attribute:NSLayoutAttributeNotAnAttribute 178 | multiplier:1 179 | constant:height]; 180 | // must add width constraint for control,because scrollView's width up to its 181 | // subViews 182 | NSLayoutConstraint *widthConstraint = 183 | [NSLayoutConstraint constraintWithItem:control 184 | attribute:NSLayoutAttributeWidth 185 | relatedBy:NSLayoutRelationEqual 186 | toItem:self 187 | attribute:NSLayoutAttributeWidth 188 | multiplier:1 189 | constant:0]; 190 | 191 | [self addConstraints:@[ 192 | leftConstraint, 193 | topConstraint, 194 | rightConstraint, 195 | heightConstraint, 196 | widthConstraint 197 | ]]; 198 | } 199 | 200 | - (void)relayoutLoadingFooterWithHeight:(CGFloat)height { 201 | NSLog(@"height is %f", height); 202 | } 203 | 204 | @end 205 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControlDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // BIRefreshHeaderDemo 4 | // 5 | // Created by AugustRush on 11/24/15. 6 | // Copyright © 2015 AugustRush. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControlDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // BIRefreshHeaderDemo 4 | // 5 | // Created by AugustRush on 11/24/15. 6 | // Copyright © 2015 AugustRush. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "BIRefresh.h" 11 | 12 | @interface ViewController () 13 | @property (weak, nonatomic) IBOutlet UITableView *tableView; 14 | @property (nonatomic, assign) NSUInteger cellCount; 15 | @end 16 | 17 | @implementation ViewController 18 | 19 | static NSString *const reuseIdentifier = @"cell"; 20 | 21 | - (void)viewDidLoad { 22 | [super viewDidLoad]; 23 | // Do any additional setup after loading the view, typically from a nib. 24 | self.cellCount = 20; 25 | self.automaticallyAdjustsScrollViewInsets = NO; 26 | [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:reuseIdentifier]; 27 | 28 | __weak typeof(self) wself = self; 29 | [self.tableView bi_addInputMethodRefreshHeaderWithHandler:^{ 30 | [wself handleRefresh]; 31 | }]; 32 | 33 | [self.tableView bi_addInputMethodLoadingFooterWithHandler:^{ 34 | [wself handleLoading]; 35 | }]; 36 | 37 | } 38 | 39 | - (void)viewDidAppear:(BOOL)animated { 40 | [super viewDidAppear:animated]; 41 | 42 | [self.tableView bi_startRefreshing]; 43 | } 44 | 45 | - (void)dealloc { 46 | // [self.tableView removeObserver:self.tableView.refreshControl forKeyPath:@"contentOffset"]; 47 | NSLog(@"%@ dealloc",NSStringFromClass([self class])); 48 | } 49 | 50 | - (void)didReceiveMemoryWarning { 51 | [super didReceiveMemoryWarning]; 52 | // Dispose of any resources that can be recreated. 53 | } 54 | 55 | #pragma mark - private methods 56 | 57 | - (void)handleRefresh { 58 | NSLog(@"refresh header %s",__PRETTY_FUNCTION__); 59 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 60 | self.cellCount = self.cellCount - 5; 61 | [self.tableView reloadData]; 62 | [self.tableView bi_stopRefreshing]; 63 | }); 64 | } 65 | 66 | - (void)handleLoading { 67 | NSLog(@"loading footer %s",__PRETTY_FUNCTION__); 68 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 69 | self.cellCount += 5; 70 | [self.tableView reloadData]; 71 | [self.tableView bi_stopLoading]; 72 | }); 73 | } 74 | 75 | #pragma mark - UITableViewDataSource methods 76 | 77 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 78 | return self.cellCount; 79 | } 80 | 81 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 82 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier forIndexPath:indexPath]; 83 | cell.textLabel.text = [NSString stringWithFormat:@"section %ld row %ld",(long)indexPath.section,(long)indexPath.row]; 84 | return cell; 85 | } 86 | 87 | #pragma mark - UITableViewDelegate methods 88 | 89 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 90 | NSLog(@"did select indexPath is %@",indexPath); 91 | } 92 | 93 | @end 94 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControlDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // BIRefreshHeaderDemo 4 | // 5 | // Created by AugustRush on 11/24/15. 6 | // Copyright © 2015 AugustRush. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControlDemoTests/BIRefreshControlDemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // BIRefreshHeaderDemoTests.m 3 | // BIRefreshHeaderDemoTests 4 | // 5 | // Created by AugustRush on 11/24/15. 6 | // Copyright © 2015 AugustRush. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface BIRefreshHeaderDemoTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation BIRefreshHeaderDemoTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControlDemoTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControlDemoUITests/BIRefreshControlDemoUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // BIRefreshHeaderDemoUITests.m 3 | // BIRefreshHeaderDemoUITests 4 | // 5 | // Created by AugustRush on 11/24/15. 6 | // Copyright © 2015 AugustRush. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface BIRefreshHeaderDemoUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation BIRefreshHeaderDemoUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /BIRefreshControlDemo/BIRefreshControlDemoUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BIRefreshControl 2 | A fully custom refresh/loading control. 3 | 4 | # Demo 5 | 6 | ![](https://github.com/AugustRush/BIRefreshControl/blob/master/rotaion.gif) -------------------------------------------------------------------------------- /rotaion.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AugustRush/BIRefreshControl/7cfc352aee9449d2e4a3487030081cd18a25ddfc/rotaion.gif --------------------------------------------------------------------------------