Browse files

Merge pull request #11 from andyduke/master

Added shade for page turning
  • Loading branch information...
2 parents 36c72ca + ed4a33c commit c2df511c6c5a98e9eb6b9ccfb57681a0f7af09a1 @Reefaq committed Oct 25, 2011
Showing with 60 additions and 0 deletions.
  1. +4 −0 .gitignore
  2. +7 −0 Classes/AFKPageFlipper.h
  3. +49 −0 Classes/AFKPageFlipper.m
View
4 .gitignore
@@ -0,0 +1,4 @@
+
+Classes/.DS_Store
+
+.DS_Store
View
7 Classes/AFKPageFlipper.h
@@ -40,6 +40,13 @@ typedef enum {
UIView *currentView;
UIView *newView;
+ // shadows
+ CALayer *frontLayerShadow;
+ CALayer *backLayerShadow;
+ CALayer *leftLayerShadow;
+ CALayer *rightLayerShadow;
+ // shadows
+
CALayer *backgroundAnimationLayer;
CALayer *flipAnimationLayer;
CALayer *blankFlipAnimationLayerOnLeft1;
View
49 Classes/AFKPageFlipper.m
@@ -217,6 +217,43 @@ - (void) initFlip {
frontLayer.transform = CATransform3DMakeRotation(M_PI, 0, 1.0, 0);
[flipAnimationLayer addSublayer:frontLayer];
+
+ // shadows
+ frontLayerShadow = [CALayer layer];
+ frontLayerShadow.frame = frontLayer.bounds;
+ frontLayerShadow.doubleSided = NO;
+ frontLayerShadow.masksToBounds = YES;
+ frontLayerShadow.opacity = 0;
+ frontLayerShadow.backgroundColor = [UIColor blackColor].CGColor;
+ [frontLayer addSublayer:frontLayerShadow];
+
+ backLayerShadow = [CALayer layer];
+ backLayerShadow.frame = backLayer.bounds;
+ backLayerShadow.doubleSided = NO;
+ backLayerShadow.masksToBounds = YES;
+ backLayerShadow.opacity = 0;
+ backLayerShadow.backgroundColor = [UIColor blackColor].CGColor;
+ [backLayer addSublayer:backLayerShadow];
+
+
+ leftLayerShadow = [CALayer layer];
+ leftLayerShadow.frame = leftLayer.bounds;
+ leftLayerShadow.doubleSided = NO;
+ leftLayerShadow.masksToBounds = YES;
+ leftLayerShadow.opacity = 0.0;
+ leftLayerShadow.backgroundColor = [UIColor blackColor].CGColor;
+ [leftLayer addSublayer:leftLayerShadow];
+
+ rightLayerShadow = [CALayer layer];
+ rightLayerShadow.frame = rightLayer.bounds;
+ rightLayerShadow.doubleSided = NO;
+ rightLayerShadow.masksToBounds = YES;
+ rightLayerShadow.opacity = 0.0;
+ rightLayerShadow.backgroundColor = [UIColor blackColor].CGColor;
+ [rightLayer addSublayer:rightLayerShadow];
+ // shadows
+
+
UIInterfaceOrientation orient = [UIApplication sharedApplication].statusBarOrientation;
UIImage* flipImage;
@@ -613,13 +650,25 @@ - (void) setFlipProgress:(float) progress setDelegate:(BOOL) setDelegate animate
[flipAnimationLayer removeAllAnimations];
+ // shadows
+ CGFloat newShadowOpacity = progress;
+ if (endFlipAngle > startFlipAngle) newShadowOpacity = 1.0 - progress;
+ // shadows
+
if (duration < 0.35) {
duration = 0.35;
}
[UIView beginAnimations:@"FLIP1" context:nil];
[UIView setAnimationDuration:duration];
flipAnimationLayer.transform = endTransform;
+
+ // shadows
+ frontLayerShadow.opacity = 1.0 - newShadowOpacity;
+ backLayerShadow.opacity = newShadowOpacity;
+ leftLayerShadow.opacity = 0.5 - newShadowOpacity;
+ rightLayerShadow.opacity = newShadowOpacity - 0.5;
+ // shadows
[UIView commitAnimations];
if (pageDifference > 1) {

0 comments on commit c2df511

Please sign in to comment.