Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add navigationTranslucent property and 
fix bugs caused by translucent #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
3 changes: 2 additions & 1 deletion CBStoreHouseRefreshControl/ContentViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ - (void)viewDidLoad {
self.navigationController.navigationBar.barTintColor = [UIColor colorWithWhite:0.1 alpha:1];
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor whiteColor]};
self.navigationController.navigationBar.translucent = NO;

self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bg_pattern"]];
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
Expand All @@ -35,7 +36,7 @@ - (void)viewDidLoad {
self.tableView.tableFooterView = footer;

// Let the show begins
self.storeHouseRefreshControl = [CBStoreHouseRefreshControl attachToScrollView:self.tableView target:self refreshAction:@selector(refreshTriggered:) plist:@"storehouse" color:[UIColor whiteColor] lineWidth:1.5 dropHeight:80 scale:1 horizontalRandomness:150 reverseLoadingAnimation:YES internalAnimationFactor:0.5];
self.storeHouseRefreshControl = [CBStoreHouseRefreshControl attachToScrollView:self.tableView target:self refreshAction:@selector(refreshTriggered:) plist:@"storehouse" color:[UIColor whiteColor] lineWidth:1.5 dropHeight:80 scale:1 horizontalRandomness:150 reverseLoadingAnimation:YES internalAnimationFactor:0.5 navigationTranslucent:self.navigationController.navigationBar.translucent];

//self.storeHouseRefreshControl = [CBStoreHouseRefreshControl attachToScrollView:self.tableView target:self refreshAction:@selector(refreshTriggered:) plist:@"AKTA" color:[UIColor whiteColor] lineWidth:2 dropHeight:80 scale:0.7 horizontalRandomness:300 reverseLoadingAnimation:NO internalAnimationFactor:0.7];
}
Expand Down
6 changes: 4 additions & 2 deletions Class/CBStoreHouseRefreshControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
+ (CBStoreHouseRefreshControl*)attachToScrollView:(UIScrollView *)scrollView
target:(id)target
refreshAction:(SEL)refreshAction
plist:(NSString *)plist;
plist:(NSString *)plist
navigationTranslucent:(BOOL)navigationTranslucent;

+ (CBStoreHouseRefreshControl*)attachToScrollView:(UIScrollView *)scrollView
target:(id)target
Expand All @@ -25,7 +26,8 @@
scale:(CGFloat)scale
horizontalRandomness:(CGFloat)horizontalRandomness
reverseLoadingAnimation:(BOOL)reverseLoadingAnimation
internalAnimationFactor:(CGFloat)internalAnimationFactor;
internalAnimationFactor:(CGFloat)internalAnimationFactor
navigationTranslucent:(BOOL)navigationTranslucent;

- (void)scrollViewDidScroll;

Expand Down
11 changes: 8 additions & 3 deletions Class/CBStoreHouseRefreshControl.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ @interface CBStoreHouseRefreshControl () <UIScrollViewDelegate>
@property (nonatomic) CGFloat internalAnimationFactor;
@property (nonatomic) int horizontalRandomness;
@property (nonatomic) BOOL reverseLoadingAnimation;
@property (nonatomic) BOOL navigationTranslucent;

@end

Expand All @@ -50,6 +51,7 @@ + (CBStoreHouseRefreshControl*)attachToScrollView:(UIScrollView *)scrollView
target:(id)target
refreshAction:(SEL)refreshAction
plist:(NSString *)plist
navigationTranslucent:(BOOL)navigationTranslucent
{
return [CBStoreHouseRefreshControl attachToScrollView:scrollView
target:target
Expand All @@ -61,7 +63,8 @@ + (CBStoreHouseRefreshControl*)attachToScrollView:(UIScrollView *)scrollView
scale:1
horizontalRandomness:150
reverseLoadingAnimation:NO
internalAnimationFactor:0.7];
internalAnimationFactor:0.7
navigationTranslucent:navigationTranslucent];
}

+ (CBStoreHouseRefreshControl*)attachToScrollView:(UIScrollView *)scrollView
Expand All @@ -75,6 +78,7 @@ + (CBStoreHouseRefreshControl*)attachToScrollView:(UIScrollView *)scrollView
horizontalRandomness:(CGFloat)horizontalRandomness
reverseLoadingAnimation:(BOOL)reverseLoadingAnimation
internalAnimationFactor:(CGFloat)internalAnimationFactor
navigationTranslucent:(BOOL)navigationTranslucent
{
CBStoreHouseRefreshControl *refreshControl = [[CBStoreHouseRefreshControl alloc] init];
refreshControl.dropHeight = dropHeight;
Expand All @@ -84,6 +88,7 @@ + (CBStoreHouseRefreshControl*)attachToScrollView:(UIScrollView *)scrollView
refreshControl.action = refreshAction;
refreshControl.reverseLoadingAnimation = reverseLoadingAnimation;
refreshControl.internalAnimationFactor = internalAnimationFactor;
refreshControl.navigationTranslucent = navigationTranslucent;
[scrollView addSubview:refreshControl];

// Calculate frame according to points max width and height
Expand Down Expand Up @@ -136,7 +141,7 @@ + (CBStoreHouseRefreshControl*)attachToScrollView:(UIScrollView *)scrollView

- (void)scrollViewDidScroll
{
if (self.originalTopContentInset == 0) self.originalTopContentInset = self.scrollView.contentInset.top;
if (self.originalTopContentInset == 0 && _navigationTranslucent) self.originalTopContentInset = self.scrollView.contentInset.top;
self.center = CGPointMake([UIScreen mainScreen].bounds.size.width/2, self.realContentOffsetY*krelativeHeightFactor);
if (self.state == CBStoreHouseRefreshControlStateIdle)
[self updateBarItemsWithProgress:self.animationProgress];
Expand Down Expand Up @@ -267,7 +272,7 @@ - (void)finishingLoading
{
self.state = CBStoreHouseRefreshControlStateDisappearing;
UIEdgeInsets newInsets = self.scrollView.contentInset;
newInsets.top = self.originalTopContentInset;
newInsets.top = self.originalTopContentInset * _navigationTranslucent;
[UIView animateWithDuration:kdisappearDuration animations:^(void) {
self.scrollView.contentInset = newInsets;
} completion:^(BOOL finished) {
Expand Down