Skip to content

Commit

Permalink
Full-page shadowing on top page.
Browse files Browse the repository at this point in the history
  • Loading branch information
brow committed Apr 20, 2010
1 parent fb38bf3 commit 33195fb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions Leaves/LeavesView.h
Expand Up @@ -14,6 +14,7 @@

@interface LeavesView : UIView {
CALayer *topPage;
CALayer *topPageOverlay;
CAGradientLayer *topPageShadow;

CALayer *topPageReverse;
Expand Down
6 changes: 6 additions & 0 deletions Leaves/LeavesView.m
Expand Up @@ -31,6 +31,9 @@ - (id)initWithFrame:(CGRect)frame {
topPage.contentsGravity = kCAGravityLeft;
topPage.backgroundColor = [[UIColor whiteColor] CGColor];

topPageOverlay = [[CALayer alloc] init];
topPageOverlay.backgroundColor = [[[UIColor blackColor] colorWithAlphaComponent:0.2] CGColor];

topPageShadow = [[CAGradientLayer alloc] init];
topPageShadow.colors = [NSArray arrayWithObjects:
(id)[[[UIColor blackColor] colorWithAlphaComponent:0.6] CGColor],
Expand Down Expand Up @@ -71,6 +74,7 @@ - (id)initWithFrame:(CGRect)frame {
bottomPageShadow.endPoint = CGPointMake(1,0.5);

[topPage addSublayer:topPageShadow];
[topPage addSublayer:topPageOverlay];
[topPageReverse addSublayer:topPageReverseImage];
[topPageReverse addSublayer:topPageReverseOverlay];
[topPageReverse addSublayer:topPageReverseShading];
Expand Down Expand Up @@ -162,6 +166,7 @@ - (void) setLayerFrames {
0,
40,
bottomPage.bounds.size.height);
topPageOverlay.frame = topPage.bounds;
}

- (void) didTurnPageBackward {
Expand Down Expand Up @@ -196,6 +201,7 @@ - (void) setLeafEdge:(CGFloat)aLeafEdge {
leafEdge = aLeafEdge;
topPageShadow.opacity = MIN(1.0, 4*(1-leafEdge));
bottomPageShadow.opacity = MIN(1.0, 4*leafEdge);
topPageOverlay.opacity = MIN(1.0, 4*(1-leafEdge));
[self setLayerFrames];
}

Expand Down

0 comments on commit 33195fb

Please sign in to comment.