From 81e45c4f29d94e60e520cac37285b059472cbcee Mon Sep 17 00:00:00 2001 From: Pavel Yurchenko Date: Tue, 1 Jul 2014 11:24:50 +0300 Subject: [PATCH 1/2] Implemented ability to set inactive border color instead of just simple grey --- AAPullToRefresh/AAPullToRefresh.h | 1 + AAPullToRefresh/AAPullToRefresh.m | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/AAPullToRefresh/AAPullToRefresh.h b/AAPullToRefresh/AAPullToRefresh.h index 8b89034..016e296 100644 --- a/AAPullToRefresh/AAPullToRefresh.h +++ b/AAPullToRefresh/AAPullToRefresh.h @@ -26,6 +26,7 @@ typedef NS_ENUM(NSUInteger, AAPullToRefreshPosition) { @property (nonatomic, assign) CGFloat threshold; @property (nonatomic, strong) UIImage *imageIcon; @property (nonatomic, strong) UIColor *borderColor; +@property (nonatomic, strong) UIColor *inactiveBorderColor; @property (nonatomic, assign) CGFloat borderWidth; - (id)initWithImage:(UIImage *)image position:(AAPullToRefreshPosition)position; diff --git a/AAPullToRefresh/AAPullToRefresh.m b/AAPullToRefresh/AAPullToRefresh.m index 01a3818..382c4cf 100644 --- a/AAPullToRefresh/AAPullToRefresh.m +++ b/AAPullToRefresh/AAPullToRefresh.m @@ -40,6 +40,8 @@ @interface AAPullToRefreshBackgroundLayer : CALayer @property (nonatomic, assign) CGFloat outlineWidth; @property (nonatomic, assign, getter = isGlow) BOOL glow; +@property (nonatomic, strong) UIColor *inactiveBorderColor; + - (id)initWithBorderWidth:(CGFloat)width; @end @@ -67,7 +69,7 @@ - (void)drawInContext:(CGContextRef)ctx CGContextFillEllipseInRect(ctx,CGRectInset(self.bounds, self.outlineWidth, self.outlineWidth)); //Draw circle outline - CGContextSetStrokeColorWithColor(ctx, [UIColor colorWithWhite:0.4f alpha:0.9f].CGColor); + CGContextSetStrokeColorWithColor(ctx, self.inactiveBorderColor.CGColor); CGContextSetLineWidth(ctx, self.outlineWidth); CGContextStrokeEllipseInRect(ctx, CGRectInset(self.bounds, self.outlineWidth, self.outlineWidth)); } @@ -104,6 +106,16 @@ @interface AAPullToRefresh() @implementation AAPullToRefresh +- (void)setInactiveBorderColor:(UIColor *)inactiveBorderColor +{ + self.backgroundLayer.inactiveBorderColor = inactiveBorderColor; +} + +- (UIColor*)inactiveBorderColor +{ + return self.backgroundLayer.inactiveBorderColor; +} + #pragma mark - init - (id)initWithImage:(UIImage *)image position:(AAPullToRefreshPosition)position { @@ -139,6 +151,7 @@ - (void)_commonInit backgroundLayer.frame = self.bounds; [self.layer addSublayer:backgroundLayer]; self.backgroundLayer = backgroundLayer; + self.inactiveBorderColor = [UIColor colorWithWhite:0.4f alpha:0.9f]; if (!self.imageIcon) self.imageIcon = [UIImage imageNamed:@"centerIcon"]; From 217a9ea897c45a3ee3d268319585a2abcf5d5fe5 Mon Sep 17 00:00:00 2001 From: Pavel Yurchenko Date: Tue, 1 Jul 2014 16:11:07 +0300 Subject: [PATCH 2/2] Fixed occasional crash on destroying scroll view: removing observer on destruction --- AAPullToRefresh/AAPullToRefresh.m | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/AAPullToRefresh/AAPullToRefresh.m b/AAPullToRefresh/AAPullToRefresh.m index 382c4cf..6b60727 100644 --- a/AAPullToRefresh/AAPullToRefresh.m +++ b/AAPullToRefresh/AAPullToRefresh.m @@ -480,4 +480,9 @@ - (void)setBorderColor:(UIColor *)borderColor _shapeLayer.strokeColor = _borderColor.CGColor; } +-(void)dealloc +{ + [self.scrollView removeObserver:self forKeyPath:@"contentOffset"]; +} + @end