问题描述
我尝试模仿NavigationViewController
,非常类似于iPhone
中的默认MailApp
I Try to imitate the NavigationViewController
, very similar to default MailApp
in iPhone
单击邮件摘要"时,它应插入邮件详细信息,并且当单击"后退"按钮时,将滑动邮件摘要"视图-in 再次返回.
When clicking on a Mail summary, it should slide-in the mail details, and when BACK button is clicked, Mail Summary view is to be slided-in back again.
这就是我动画从摘要到细节"(removeFromSuperView
)过渡的过程
This is what I have to animate the transition from Summary To Detail (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
)
This is what I have to animate the transition from Detail To Summary (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];
现在,我的第一部分代码运行良好!而在第二部分中,我仅能实现淡入淡出的动画.如何引入幻灯片过渡?
Now, that My First part of code is working well! Where-as the second part, I am just able to achieve the Fade-in animation. How can I bring in the slide transition?
推荐答案
我只需要为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];
Swift的更新:
let transition = CATransition()
transition.type = kCATransitionPush
transition.subtype = kCATransitionFromLeft
parentView.layer.add(transition, forKey: nil)
parentView.addSubview(myVC.view)
这篇关于在addSubView中从左向右添加幻灯片动画(过渡)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!