Add Slide In from Left to Right animation(transition) in addSubView Add Slide In from Left to Right animation(transition) in addSubView objective-c objective-c

Add Slide In from Left to Right animation(transition) in addSubView


I just need to choose kCATransitionPush type for my CATransition

    CATransition *transition = [CATransition animation];    transition.duration = 0.5;    transition.type = kCATransitionPush;    transition.subtype = kCATransitionFromLeft;    [transition setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];    [parentView.layer addAnimation:transition forKey:nil];    [parentView addSubview:myVC.view];

Update for Swift:

    let transition = CATransition()    transition.type = kCATransitionPush    transition.subtype = kCATransitionFromLeft    parentView.layer.add(transition, forKey: nil)    parentView.addSubview(myVC.view)


Or you could check out : HorizontalSlide Segue (just google it I cant get the link, on mobile) its a great sliding transition that is simply a segue that you add from view A to B....

On a side note, if this is in a nav controller, a push or a pop should have a slide animation by default...