Show animation when addsubview 1


If you want to add a subview with animation, try this simple snippet:

PS: Replace myView with the name of the view you want to replace.

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

Leave a comment

Your email address will not be published. Required fields are marked *

One thought on “Show animation when addsubview

  • DavidiOS

    De gran ayuda este post. Muchas gracias. Os dejo una actualización para Swift 4.0. Un saludo.

    let animation = CATransition()
    animation.duration = 0.5
    animation.type = kCATransitionReveal
    animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseIn)
    myView.layer.add(transition, forKey: kCATransitionReveal)