Skip to content
Browse files

Added support for using the enabled property to disable the refresh c…

…ontrol.
  • Loading branch information...
1 parent 06e26ff commit 59dc22637e19fe7b5e166f11b82339cc6ef81b71 @nicklockwood nicklockwood committed Aug 12, 2012
Showing with 13 additions and 5 deletions.
  1. +13 −5 ODRefreshControl/ODRefreshControl.m
View
18 ODRefreshControl/ODRefreshControl.m
@@ -73,6 +73,7 @@ - (id)initInScrollView:(UIScrollView *)scrollView
_shapeLayer.shadowOffset = CGSizeMake(0, 1);
_shapeLayer.shadowOpacity = 0.4;
_shapeLayer.shadowRadius = 0.5;
+ _shapeLayer.hidden = !self.enabled;
[self.layer addSublayer:_shapeLayer];
_arrowLayer = [CAShapeLayer layer];
@@ -90,10 +91,16 @@ - (id)initInScrollView:(UIScrollView *)scrollView
- (void)dealloc
{
- [self.scrollView removeObserver:self forKeyPath:@"contentOffset"];
+ [self.scrollView removeObserver:self forKeyPath:@"contentOffset" context:nil];
self.scrollView = nil;
}
+- (void)setEnabled:(BOOL)enabled
+{
+ super.enabled = enabled;
+ _shapeLayer.hidden = !self.enabled;
+}
+
- (void)setTintColor:(UIColor *)tintColor
{
_tintColor = tintColor;
@@ -112,6 +119,11 @@ - (UIActivityIndicatorViewStyle)activityIndicatorViewStyle
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
+ if (!self.enabled)
+ {
+ return;
+ }
+
CGFloat offset = [[change objectForKey:@"new"] CGPointValue].y;
if (_refreshing) {
@@ -139,10 +151,6 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
} else {
return;
}
- } else {
- if (offset >= 0) {
- return;
- }
}
}

0 comments on commit 59dc226

Please sign in to comment.
Something went wrong with that request. Please try again.