Supongo que quiere crear su propia animación. El mes pasado jugué con algo así. Mi solución fue agregar una vista personalizada (tal vez tomada desde un controlador de vista) a la vista actual como una superposición. Esto funciona con capas, también.
Primero busca la imagen de su controlador de vista "futuro" o "presente", como lo hizo en el ejemplo de código anterior. Normalmente, el contenido de los controladores de vista debe estar disponible mientras se procesa en el contexto.
Ahora usted tiene la imagen. La manipulación de la imagen debe ser hecha por usted.
Agregue la imagen a un UIImageView. Este ImageView se puede agregar como subvista o capa. Ahora tiene una capa donde puede dibujar libremente sobre su interfaz de usuario real. A veces tiene que mover la capa o ver alrededor, de modo que superpone perfectamente su vista. Esto depende de la configuración de tu vista. Si está trabajando con Tableviews, agregar una subvista no es tan fácil. Así que mejor usa la capa.
Después de todo el trabajo realizado, presente el nuevo controlador de vista sin animación, para que aparezca inmediatamente.
Elimine la capa o vista de su vista principal después de que el trabajo haya terminado, y limpie.
Esto suena complicado, pero una vez que lo haya hecho, tiene una plantilla para eso. En "WWDC 2011, Session 309 Introducing Interface Builder Storyboarding", Apple introdujo 'segues personalizados', donde encontrará un mecanismo para exactamente lo que quiere hacer. El siguiente código es un recorte de un proyecto anterior y de alguna manera es complicado y debe ser limpiado. Pero para mostrar el principio esto debería funcionar:
-(void) animate {
static LargeViewController* lvc = [[LargeViewController alloc] init];
UIGraphicsBeginImageContextWithOptions(self.bounds.size, view.opaque, [[UIScreen mainScreen] scale]);
[lvc.view.layer renderInContext:UIGraphicsGetCurrentContext()];
// Create a ImageView to display your "zoomed" image
static UIImageView* displayView = [[UIImageView alloc] initWithFrame:self.view.frame];
static UIImage * img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// Add your image to the view
displayView.image = img;
// insert the view above your actual view, adjust coordinates in the
// frame property of displayView if overlay is misaligned
[[self.view] addSubview:displayView];
// alternatively you can use the layer
// [self.view.layer addSublayer:displayView.layer];
// draw the imageView
[displayView setNeedsDisplay];
// do something in background. You may create your own
// construction, i.e. using a timer
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSDate *now = [NSDate date];
NSTimeInterval animationDuration = 3.;
NSTimeInterval t = -[now timeIntervalSinceNow];
while (t < animationDuration) {
t = -[now timeIntervalSinceNow];
// Do some animation here, by manipulation the image
// or the displayView
// <calculate animation>, do something with img
// you have exact timing information in t,
// so you can set the scalefactor derived from t
// You must not use an UIImage view. You can create your own view
// and do sth. in draw rect. Do whatever you want,
// the results will appear
// in the view if you added a subview
// or in a layer if you are using the layer
dispatch_sync(dispatch_get_main_queue(), ^{
// display the result
displayView.image = img;
[displayView setNeedsDisplay];
});
}
});
// now the animation is done, present the real view controller
[self presentModalViewController:lvc animated:NO];
// and clean up here
}
Finalmente tuve tiempo de probar sus sugerencias, muy detalladas. ¡Funciona de maravilla! ¡Muchas gracias por tu aportación! Y también, la sesión 309 de la WWDC 2011 con conexiones personalizadas también habría funcionado muy bien. –