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

后端 未结 2 1209
轮回少年
轮回少年 2021-02-02 15:07

I Try to imitate the NavigationViewController, very similar to default MailApp in iPhone

When clicking on a Mail summary, it shoul

2条回答
  •  囚心锁ツ
    2021-02-02 15:32

    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)
    

提交回复
热议问题