Skip to content

Commit

Permalink
Update snapshot methods using ios7 native method snapshotViewAfterScr…
Browse files Browse the repository at this point in the history
…eenUpdates

Improving transition quality
  • Loading branch information
andresbrun committed Sep 19, 2013
1 parent 42fa4a7 commit 7c7adad
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 36 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion ABCustomUINavigationControllerExample/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[ViewController alloc] initViewController];
//self.window.rootViewController = [[FlipSquaresNavigationController alloc] initWithRootViewController:self.viewController];
// self.window.rootViewController = [[FlipSquaresNavigationController alloc] initWithRootViewController:self.viewController];
self.window.rootViewController = [[CubeNavigationController alloc] initWithRootViewController:self.viewController];
[self.window makeKeyAndVisible];

Expand Down
2 changes: 1 addition & 1 deletion CustomUINavigationController/Categories/UIView+ABExtras.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
Methot that capture a image from that view
*/
- (UIImageView *) imageInNavController: (UINavigationController *) navController;
- (UIView *) viewInNavController: (UINavigationController *) navController;
- (UIView *) createSnapshotView;
/**
Method that adds a view with color in that view
*/
Expand Down
8 changes: 2 additions & 6 deletions CustomUINavigationController/Categories/UIView+ABExtras.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,9 @@ - (UIImageView *) imageInNavController: (UINavigationController *) navController
return currentView;
}

- (UIView *) viewInNavController: (UINavigationController *) navController
- (UIView *) createSnapshotView
{
//Fix the position to handle status bar and navigation bar
float yPosition = [navController calculateYPosition];
CGRect rect = CGRectMake(0, yPosition, self.frame.size.width, self.frame.size.height);

UIView *currentView = [self resizableSnapshotFromRect:rect withCapInsets:UIEdgeInsetsZero];
UIView *currentView = [self snapshotViewAfterScreenUpdates:YES];

return currentView;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ -(void)pushViewController:(UIViewController *)viewController animated:(BOOL)anim

UIViewController *currentVC = [self visibleViewController];

UIImageView *fromImageView = [currentVC.view imageInNavController:self];
UIView *fromView = [currentVC.view createSnapshotView];

//Issue with autosizing, we nned to set the frame before take the image
[viewController.view setFrame:currentVC.view.frame]; //Resize new view manually
UIImageView *toImageView = [viewController.view imageInNavController:self];
UIView *toView = [viewController.view createSnapshotView];

[currentVC.view setAlpha:0.0];

[self makeCubeAnimationFrom:fromImageView to:toImageView direction:self.cubeAnimationType withCompletion:^{
[self makeCubeAnimationFrom:fromView to:toView direction:self.cubeAnimationType withCompletion:^{

//Do the push
[super pushViewController:viewController animated:NO];
Expand All @@ -84,7 +84,7 @@ -(UIViewController *)popViewControllerAnimated:(BOOL)animated
if (animated) {
UIViewController *currentVC = [self visibleViewController];

UIImageView *fromImageView = [currentVC.view imageInNavController:self];
UIView *fromImageView = [currentVC.view createSnapshotView];

int index = [self.viewControllers indexOfObject:currentVC];

Expand All @@ -93,7 +93,7 @@ -(UIViewController *)popViewControllerAnimated:(BOOL)animated
//Issue with autosizing, we nned to set the frame before take the image
UIViewController *toViewController = [self.viewControllers objectAtIndex:index-1];
[toViewController.view setFrame:currentVC.view.frame]; //Resize new view manually
UIImageView *toImageView = [toViewController.view imageInNavController:self];
UIView *toImageView = [toViewController.view createSnapshotView];

[currentVC.view setAlpha:0.0];

Expand Down Expand Up @@ -131,13 +131,13 @@ - (NSArray *)popToRootViewControllerAnimated:(BOOL)animated
//Issue with autosizing, we nned to set the frame before take the image
[rootVC.view setFrame:currentVC.view.frame]; //Resize new view manually

UIImageView *fromImageView = [currentVC.view imageInNavController:self];
UIImageView *toImageView = [rootVC.view imageInNavController:self];
UIView *fromView = [currentVC.view createSnapshotView];
UIView *toView = [rootVC.view createSnapshotView];

[currentVC.view setAlpha:0.0];

__block NSArray *stackVCs;
[self makeCubeAnimationFrom:fromImageView to:toImageView direction:self.cubeAnimationType withCompletion:^{
[self makeCubeAnimationFrom:fromView to:toView direction:self.cubeAnimationType withCompletion:^{

stackVCs = [super popToRootViewControllerAnimated:NO];
}];
Expand All @@ -164,13 +164,13 @@ - (NSArray *)popToViewController:(UIViewController *)viewController animated:(BO
//Issue with autosizing, we nned to set the frame before take the image
[viewController.view setFrame:currentVC.view.frame]; //Resize new view manually

UIImageView *fromImageView = [currentVC.view imageInNavController:self];
UIImageView *toImageView = [viewController.view imageInNavController:self];
UIView *fromView = [currentVC.view createSnapshotView];
UIView *toView = [viewController.view createSnapshotView];

[currentVC.view setAlpha:0.0];

__block NSArray *stackVCs;
[self makeCubeAnimationFrom:fromImageView to:toImageView direction:self.cubeAnimationType withCompletion:^{
[self makeCubeAnimationFrom:fromView to:toView direction:self.cubeAnimationType withCompletion:^{

stackVCs = [super popToViewController:viewController animated:NO];
}];
Expand All @@ -190,7 +190,7 @@ - (NSArray *)popToViewController:(UIViewController *)viewController animated:(BO
/**
Function that creates the cube animation transition between fromImage and toImage
*/
- (void) makeCubeAnimationFrom: (UIImageView *) fromImage to: (UIImageView *) toImage direction: (CubeAnimationType) animationType withCompletion: (void(^)(void))completion
- (void) makeCubeAnimationFrom: (UIView *) fromImage to: (UIView *) toImage direction: (CubeAnimationType) animationType withCompletion: (void(^)(void))completion
{
//We need to calculate the animation direcction
int dir=pushingVC?1:-1;
Expand Down
58 changes: 42 additions & 16 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,46 @@
The MIT License (MIT)
Información de una película
Nombre
Fecha
Escenas
Autor + cita
ImageLarge para mainscreen
ImageMedium para tarjeta

Copyright (c) 2012 Andrés Brun Moreno
Frases
Autor (Nombre + Images)
Cita

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
Escenas
Imagen
Descripcion

Películas
o Gladiator
o Pulp Fiction
o El Padrino
o La chaqueta metálica
Lo que el viento se llevó
CasaBlanca
La lista de shindler
o Amelie
Resorvoir Dog
Pretty woman
o American History X
o El Silencio de los Corderos
o El exorcista
Saw I
Dracula de Bran Stoker
La Milla Verde
o Snach, Cerdos y Diamantes
o Watchmen
o Matrix
o StarWars
300
Inception
Terminator II
Die Hard
La Vida es Bella
Men In Black


The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 comments on commit 7c7adad

Please sign in to comment.