CATransition 是如何工作的?
我有两个视图,一个是aView,另一个是bView,aView上有一个按钮,我点击按钮,我会跳转到bView,请看代码
-(IBAction)jump2b:(id)sender{
CATransition *animation = [CATransition animation];
animation.delegate = self;
animation.duration = 0.25f;
animation.timingFunction = UIViewAnimationCurveEaseInOut;
animation.fillMode = kCAFillModeForwards;
animation.removedOnCompletion = NO;
animation.type = kCATransitionPush;
animation.subtype = kCATransitionFromTop;
[bView.view.layer addAnimation:animation forKey:@"animation"];
}
它不能很好地工作,它可以跳转,所以我该怎么办?谢谢
i have two views,one is aView,another is bView, there is a button on aView,i click the button ,i will jump to bView,please see the code
-(IBAction)jump2b:(id)sender{
CATransition *animation = [CATransition animation];
animation.delegate = self;
animation.duration = 0.25f;
animation.timingFunction = UIViewAnimationCurveEaseInOut;
animation.fillMode = kCAFillModeForwards;
animation.removedOnCompletion = NO;
animation.type = kCATransitionPush;
animation.subtype = kCATransitionFromTop;
[bView.view.layer addAnimation:animation forKey:@"animation"];
}
it can not work well,it can jump,so what can i do?thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您忘记在最后实际添加视图...
您不使用 UIView 动画块有什么原因吗?这是自 iOS 4 以来推荐的动画方法。使用 UIView 的 transitionFromView:toView:duration:options:completion: 应该适合你...
我使用 UIViewAnimationOptionTransitionCurlUp 作为过渡选项的示例,但你可以选择任何 UIViewAnimationOption。
You forgot to actually add the view at the end...
Is there reason why you're not using UIView animation blocks? It's the recommended method for animations since iOS 4. Using UIView's transitionFromView:toView:duration:options:completion: should work for you...
I used UIViewAnimationOptionTransitionCurlUp as an example for the transition option, but you can choose any UIViewAnimationOption.