Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added overlay on top of pages in DECK mode, that way you don't see th…

…e weird shadow through the translucent page. Changed the background colors to be closer to safari. Modified slightly the shadows of pages.
  • Loading branch information...
commit 496c68e0369d48a05b22b401fc902b1c0fef21f1 1 parent ba7eec6
phcorcoran authored
45 Classes/HGPageScrollView/HGPageScrollView.m
@@ -93,6 +93,7 @@ - (void) prepareForDataUpdate : (HGPageScrollViewUpdateMethod) method withIndexS
93 93 // managing selection and scrolling
94 94 - (void) updateVisiblePages;
95 95 - (void) setAlphaForPage : (UIView*) page;
  96 +- (void) setOpacity:(CGFloat)alpha forObstructionLayerOfPage:(UIView *)page;
96 97 - (void) preparePage : (HGPageView *) page forMode : (HGPageScrollViewMode) mode;
97 98 - (void) setViewMode:(HGPageScrollViewMode)mode animated:(BOOL)animated; //toggles selection/deselection
98 99
@@ -153,8 +154,8 @@ - (void) awakeFromNib{
153 154 // set gradient for background view
154 155 CAGradientLayer *glayer = [CAGradientLayer layer];
155 156 glayer.frame = _pageDeckBackgroundView.bounds;
156   - UIColor *topColor = [UIColor colorWithRed:0.8 green:0.8 blue:0.8 alpha:1.0]; //light blue-gray
157   - UIColor *bottomColor = [UIColor colorWithRed:0.4 green:0.4 blue:0.4 alpha:1.0]; //dark blue-gray
  157 + UIColor *topColor = [UIColor colorWithRed:0.57 green:0.63 blue:0.68 alpha:1.0]; //light blue-gray
  158 + UIColor *bottomColor = [UIColor colorWithRed:0.31 green:0.41 blue:0.48 alpha:1.0]; //dark blue-gray
158 159 glayer.colors = [NSArray arrayWithObjects:(id)[topColor CGColor], (id)[bottomColor CGColor], nil];
159 160 [_pageDeckBackgroundView.layer insertSublayer:glayer atIndex:0];
160 161
@@ -330,7 +331,8 @@ - (void) deselectPageAnimated : (BOOL) animated;
330 331 _selectedPage = [self loadPageAtIndex:selectedPageScrollIndex insertIntoVisibleIndex:visibleIndex];
331 332 _selectedPage.identityFrame = identityFrame;
332 333 _selectedPage.frame = pageFrame;
333   - _selectedPage.alpha = 1.0;
  334 + [self setOpacity:0.0 forObstructionLayerOfPage:_selectedPage];
  335 + //_selectedPage.alpha = 1.0;
334 336 [self addSubview:_selectedPage];
335 337
336 338 [self setViewMode:HGPageScrollViewModeDeck animated:animated];
@@ -462,7 +464,8 @@ - (void) setViewMode:(HGPageScrollViewMode)mode animated:(BOOL)animated;
462 464 _pageDeckSubtitleLabel.hidden = YES;
463 465 _pageSelector.hidden = YES;
464 466 _scrollView.scrollEnabled = NO;
465   - _selectedPage.alpha = 1.0;
  467 + [self setOpacity:0.0 forObstructionLayerOfPage:_selectedPage];
  468 + //_selectedPage.alpha = 1.0;
466 469 // copy _selectedPage up in the view hierarchy, to allow touch events on its entire frame
467 470 _selectedPage.frame = CGRectMake(0, headerView.frame.size.height, self.frame.size.width, _selectedPage.frame.size.height);
468 471 [self addSubview:_selectedPage];
@@ -605,11 +608,25 @@ - (void) addPageToScrollView : (HGPageView*) page atIndex : (NSInteger) index
605 608
606 609 // add shadow (use shadowPath to improve rendering performance)
607 610 page.layer.shadowColor = [[UIColor blackColor] CGColor];
608   - page.layer.shadowOffset = CGSizeMake(8.0f, 12.0f);
  611 + page.layer.shadowOffset = CGSizeMake(3.0f, 8.0f);
609 612 page.layer.shadowOpacity = 0.3f;
  613 + page.layer.shadowRadius = 7.0;
610 614 page.layer.masksToBounds = NO;
611 615 UIBezierPath *path = [UIBezierPath bezierPathWithRect:page.bounds];
612   - page.layer.shadowPath = path.CGPath;
  616 + page.layer.shadowPath = path.CGPath;
  617 +
  618 + if([page.layer.sublayers count] < 2) {
  619 + CALayer *mask = [[CALayer alloc] init];
  620 + CGSize size = page.layer.frame.size;
  621 + // FIXME: Magic Numbers :S
  622 + mask.frame = CGRectMake(64., 92., size.width, size.height);
  623 + size = page.layer.bounds.size;
  624 + mask.bounds = CGRectMake(0., 0., size.width, size.height);
  625 + mask.backgroundColor = [[UIColor blackColor] CGColor];
  626 + mask.opaque = NO;
  627 + mask.opacity = 0.0f;
  628 + [page.layer addSublayer:mask];
  629 + }
613 630
614 631 // add the page to the scroller
615 632 [_scrollView insertSubview:page atIndex:0];
@@ -620,7 +637,7 @@ - (void) addPageToScrollView : (HGPageView*) page atIndex : (NSInteger) index
620 637 - (void) insertPageInScrollView : (HGPageView *) page atIndex : (NSInteger) index animated : (BOOL) animated
621 638 {
622 639 //hide the new page before inserting it
623   - page.alpha = 0.0;
  640 + //page.alpha = 0.0;
624 641
625 642 // add the new page at the correct offset
626 643 [self addPageToScrollView:page atIndex:index];
@@ -1165,10 +1182,18 @@ - (void) setAlphaForPage : (UIView*) page
1165 1182 {
1166 1183 CGFloat delta = _scrollView.contentOffset.x - page.frame.origin.x;
1167 1184 CGFloat step = self.frame.size.width;
1168   - CGFloat alpha = 1.0 - fabs(delta/step);
1169   - if(alpha > 0.95) alpha = 1.0;
1170   - page.alpha = alpha;
  1185 + CGFloat alpha = fabs(delta/step)*2./5.;
  1186 + if(alpha > 0.2) alpha = 0.2;
  1187 + if(alpha < 0.05) alpha = 0.;
  1188 + //CGFloat alpha = 1.0 - fabs(delta/step);
  1189 + //if(alpha > 0.) alpha = 1.0;
  1190 + //page.alpha = alpha;
  1191 + [self setOpacity:alpha forObstructionLayerOfPage:page];
  1192 +}
1171 1193
  1194 +- (void)setOpacity:(CGFloat)alpha forObstructionLayerOfPage:(UIView *)page
  1195 +{
  1196 + [[page.layer.sublayers lastObject] setOpacity:alpha];
1172 1197 }
1173 1198
1174 1199
5 HGPageScrollViewSample.xcodeproj/project.pbxproj
@@ -234,6 +234,9 @@
234 234 /* Begin PBXProject section */
235 235 29B97313FDCFA39411CA2CEA /* Project object */ = {
236 236 isa = PBXProject;
  237 + attributes = {
  238 + LastUpgradeCheck = 0420;
  239 + };
237 240 buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "HGPageScrollViewSample" */;
238 241 compatibilityVersion = "Xcode 3.2";
239 242 developmentRegion = English;
@@ -338,7 +341,6 @@
338 341 GCC_OPTIMIZATION_LEVEL = 0;
339 342 GCC_WARN_ABOUT_RETURN_TYPE = YES;
340 343 GCC_WARN_UNUSED_VARIABLE = YES;
341   - PREBINDING = NO;
342 344 "PROVISIONING_PROFILE[sdk=iphoneos*]" = "C3197FD8-77C4-473A-946F-F4A6B65B86FA";
343 345 SDKROOT = iphoneos;
344 346 };
@@ -354,7 +356,6 @@
354 356 GCC_WARN_ABOUT_RETURN_TYPE = YES;
355 357 GCC_WARN_UNUSED_VARIABLE = YES;
356 358 OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
357   - PREBINDING = NO;
358 359 "PROVISIONING_PROFILE[sdk=iphoneos*]" = "C3197FD8-77C4-473A-946F-F4A6B65B86FA";
359 360 SDKROOT = iphoneos;
360 361 };

0 comments on commit 496c68e

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