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..6b60727 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"]; @@ -467,4 +480,9 @@ - (void)setBorderColor:(UIColor *)borderColor _shapeLayer.strokeColor = _borderColor.CGColor; } +-(void)dealloc +{ + [self.scrollView removeObserver:self forKeyPath:@"contentOffset"]; +} + @end