我尝试模仿NavigationViewController,非常类似于iPhone中的默认MailApp
当单击邮件摘要时,它应该滑入邮件详细信息,并且当单击“返回”按钮时,“邮件摘要”视图将被重新插入.
这是我必须动画化从摘要到细节的转换(removeFromSuperView)
CGRect temp = self.view.frame; temp.origin.x = 300; [UIView animateWithDuration:0.5 delay:0.0 options: UIViewAnimationCurveEaSEOut animations:^{ self.view.frame = temp; }completion:^(BOOL finished){ [self.view removeFromSuperview]; }];
这是我从动画到细节到摘要的过渡(addSubview)
CATransition *transition = [CATransition animation]; transition.duration = 0.5; transition.type = kCATransitionFromRight; transition.subtype = kCATransitionFade; [parentView.layer addAnimation:transition forKey:nil]; [parentView addSubview:myVC.view];
解决方法
我只需要为我的CATransition选择kCATransitionPush类型
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];