Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Class/BarItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
- (instancetype)initWithFrame:(CGRect)frame startPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint color:(UIColor *)color lineWidth:(CGFloat)lineWidth;
- (void)setupWithFrame:(CGRect)rect;
- (void)setHorizontalRandomness:(int)horizontalRandomness dropHeight:(CGFloat)dropHeight;
@property (nonatomic) UIColor *color;

@end
2 changes: 1 addition & 1 deletion Class/BarItem.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ @interface BarItem ()
@property (nonatomic) CGFloat lineWidth;
@property (nonatomic) CGPoint startPoint;
@property (nonatomic) CGPoint endPoint;
@property (nonatomic) UIColor *color;


@end

Expand Down
2 changes: 2 additions & 0 deletions Class/CBStoreHouseRefreshControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@

- (void)finishingLoading;

- (void)updateColor:(UIColor *)color;

@end
15 changes: 12 additions & 3 deletions Class/CBStoreHouseRefreshControl.m
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ + (CBStoreHouseRefreshControl*)attachToScrollView:(UIScrollView *)scrollView
// Calculate frame according to points max width and height
CGFloat width = 0;
CGFloat height = 0;
NSDictionary *rootDictionary = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:plist ofType:@"plist"]];
NSDictionary *rootDictionary = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle bundleForClass:self] pathForResource:plist ofType:@"plist"]];
NSArray *startPoints = [rootDictionary objectForKey:startPointKey];
NSArray *endPoints = [rootDictionary objectForKey:endPointKey];
for (int i=0; i<startPoints.count; i++) {
Expand Down Expand Up @@ -132,12 +132,21 @@ + (CBStoreHouseRefreshControl*)attachToScrollView:(UIScrollView *)scrollView
return refreshControl;
}

- (void)updateColor:(UIColor *)color
{
for (BarItem *barItem in self.barItems) {
barItem.color = color;
[barItem setNeedsDisplay];
}
}


#pragma mark UIScrollViewDelegate

- (void)scrollViewDidScroll
{
if (self.originalTopContentInset == 0) self.originalTopContentInset = self.scrollView.contentInset.top;
self.center = CGPointMake([UIScreen mainScreen].bounds.size.width/2, self.realContentOffsetY*krelativeHeightFactor);
self.center = CGPointMake(self.scrollView.frame.size.width * 0.5, self.realContentOffsetY*krelativeHeightFactor);
if (self.state == CBStoreHouseRefreshControlStateIdle)
[self updateBarItemsWithProgress:self.animationProgress];
}
Expand All @@ -151,7 +160,7 @@ - (void)scrollViewDidEndDragging
if (self.state == CBStoreHouseRefreshControlStateRefreshing) {

UIEdgeInsets newInsets = self.scrollView.contentInset;
newInsets.top = self.originalTopContentInset + self.dropHeight;
newInsets.top = self.originalTopContentInset;
CGPoint contentOffset = self.scrollView.contentOffset;

[UIView animateWithDuration:0 animations:^(void) {
Expand Down