UIView 过渡动画不适用于 transitionWithView:duration:options:animations:completion 方法
在 iOS 文档中,不鼓励使用 beginAnimation-commitAnimation。因此,对于动画和过渡,有一些利用 ^blocks 的新方法。但是,当我使用transitionWithView:duration:options:animations:completion方法时,我没有得到任何过渡效果。因此,如果我写:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp
forView:self.view cache:YES];
firstView.hidden = YES;
secondView.hidden = NO;
[UIView commitAnimations];
它可以工作,但如果我按照以下方式执行,
[UIView transitionWithView:self.view duration:1.0 options
UIViewAnimationCurveEaseIn|UIViewAnimationTransitionCurlUp
animations:^{
firstView.hidden = YES;
secondView.hidden = NO;
} completion:NULL
];
我不会得到任何过渡效果。我缺少什么?
In iOS Documentation usage of beginAnimation-commitAnimation is discouraged. So for animations and transitions there are new methods that make use of ^blocks. However when I use transitionWithView:duration:options:animations:completion method I get no transition effects.So if I write:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp
forView:self.view cache:YES];
firstView.hidden = YES;
secondView.hidden = NO;
[UIView commitAnimations];
it works but if I do it the following way
[UIView transitionWithView:self.view duration:1.0 options
UIViewAnimationCurveEaseIn|UIViewAnimationTransitionCurlUp
animations:^{
firstView.hidden = YES;
secondView.hidden = NO;
} completion:NULL
];
I do not get any transition effects. What am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,我已经找到了每个人都需要注意的微妙细节,以便让动画和过渡与 iOS 4 及更高版本中可用的方法一起工作。在为该方法指定动画/过渡选项时,我们必须使用以下常量:其中的“选项”一词。 编写,而不是编写
因此,我们应该
在修复转换工作正常后
OK, I've found the subtle detail everyone needs to take note of in order to get the animation and transitions work with the method available in iOS 4 and later.When specifying the animation/transition options for the method we must use the constants with the word "Option" in it. So instead of writing
we should write
after fixing that the transition worked just fine