animation addsubview uiviewanimation uiviewanimationtransition

animation - mostrar animacion cuando el addubview



addsubview uiviewanimation (3)

Quiero añadir una subvista con animación. Estoy usando añadir subvista, por lo que no muestra ninguna animación, así que quiero mostrar cualquier animación cuando hago esto ... Estoy usando el siguiente código:

UIViewController *vControllerHome = [[viewTemp alloc] initWithNibName:@"viewTemp" bundle:nil]; vControllerHome.view.frame =CGRectMake(0, 0, 320, 414); [self.view addSubview:vControllerHome.view]; self.selectedViewController = vControllerHome;

¿Alguien puede sugerir cómo hago esto?


Aquí está el código ... Solo inténtalo.

PS: Reemplace myView con el nombre de la vista que desea reemplazar.

CATransition *applicationLoadViewIn =[CATransition animation]; [applicationLoadViewIn setDuration:duration]; [applicationLoadViewIn setType:kCATransitionReveal]; [applicationLoadViewIn setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]]; [[myView layer]addAnimation:applicationLoadViewIn forKey:kCATransitionReveal];


Aquí está para bloques de animación.

[UIView transitionWithView:containerView duration:0.5 options:UIViewAnimationTransitionFlipFromRight //any animation animations:^ { [containerView addSubview:subview]; } completion:nil];


Tal vez usted pueda subclasificar el método willMove(toSuperview newSuperview: UIView?) y anular el método willMove(toSuperview newSuperview: UIView?)

Aquí está el ejemplo:

override public func willMove(toSuperview newSuperview: UIView?) { super.willMove(toSuperview: newSuperview) if let _ = newSuperview { // This view will be added to some view UIView.animate(withDuration: 0.2, delay: 0.0, usingSpringWithDamping: 0.6, initialSpringVelocity: 30.0, options: .curveEaseInOut, animations: { //... }, completion: { (finish) in }) } else { // This view will be removed } }