是否有执行使用动画块这部动画的另一种方式? [英] Is there an alternative way to perform this animation using animation blocks?

查看:133
本文介绍了是否有执行使用动画块这部动画的另一种方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前通过执行以下操作执行起来卷曲动画:

I'm currently performing a curl up animation by doing the following:

CATransition *animation = [CATransition animation];
animation.type = @"pageCurl";
animation.subtype = kCATransitionFromTop;
animation.fillMode = kCAFillModeForwards;
animation.duration = 1;
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
[[self.view.window layer] addAnimation:animation forKey:nil];

这个动画将只是进行卷页的动画,但最终你留下看着那你开始了同样的观点。没有真正的过渡想过。

This animation will simply perform a page curl animation but in the end you are left looking at the same view that you started out with. No REAL transition ever occurred.

现在使用动画块我知道你可以做些什么来的效果:

Now using animation blocks I know you can do something to the effect of:

[UIView transitionFromView:self.view
                    toView:aNewView    // a view to transition to
                  duration:1 
                   options:UIViewAnimationTransitionCurlUp|UIViewAnimationOptionCurveEaseIn
                completion:NULL];

然而,使用要转换到一个新视图的动画块, aNewView ,这是从CATransition动画高于该重用了同样的看法不同(没有真正转变以往发生)。与动画块的问题是你必须真正创造转型的新视图这是在我的情况很麻烦,因为视图是相当复杂的,我宁可不创建UIView子类。

However, using animation blocks you are transitioning to a new view, aNewView, which is different from the CATransition animation above which reuses the same view (no real transition ever occurs). The problem with the animation block is that you have to actually create the new view to transition to which is cumbersome in my case because the view is rather complicated and I'd rather not create a UIView subclass.

有没有使用动画块执行上述CATransition动画,而其周围的重建视图,或创建一个自定义子类的困难得到一个办法吗?

Is there a way to perform the above CATransition animation using animation blocks while getting around the difficulties of having to rebuild a view or create a custom subclass?

推荐答案

确定 - 所以我理解了它的人谁是有兴趣。这其实超级简单。你可以简单的使用方法: transitionWithView:时间:选择:动画:完成:

Ok - so I figured it out for anyone who is interested. It's actually super simple. You can simply use the method: transitionWithView:duration:options:animations:completion:

例如:

[UIView transitionWithView:self.view
                  duration:1
                   options:UIViewAnimationOptionTransitionCurlUp|UIViewAnimationCurveEaseIn
                animations:^{ // do anything you want here } 
                completion:NULL];

就是这样。这将显示一过渡动画回到同一视图。你可以让你想要新视图的任何变化的动画块(也许显示一些新的文本,无论...)。

That's it. This will show a transition animation back to the same view. You can make any changes you want to the new view (maybe display some new text, whatever...) in the animation block.

我希望这可以帮助别人出了线......

I hope this helps someone out down the line...

这篇关于是否有执行使用动画块这部动画的另一种方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆