UIView页面卷曲动画不适用于块

时间:2015-09-11 19:33:19

标签: ios objective-c animation uiview uiviewanimation

我正在尝试将工作的UIView动画转换为使用块。除了完成回调之外,我没有看到它们有什么不同。有人可以澄清一些我可能遗失的东西吗?

这可以按预期工作

[UIView beginAnimations:@"Curl" context:nil];
[UIView setAnimationDuration:.15];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.storyTextView cache:YES];
self.storyTextView.text = text;
[UIView commitAnimations];

这确实会改变页面的文本,但不会显示动画,只是一个即时过渡。

UIViewAnimationOptions curl = UIViewAnimationOptionTransitionCurlUp;
[UIView animateWithDuration:.15 delay:0 options:(UIViewAnimationOptionCurveEaseInOut | curl) animations:^{
    self.storyTextView.text = text;
} completion:^(BOOL finished) {
    if (finished){
        // pass
    }
}];

此外,在块样式动画中设置delay不会影响即时转换,它只会在延迟后运行完成块。

1 个答案:

答案 0 :(得分:2)

您想要尝试UIView transitionWithView而不是:

UIViewAnimationOptions curl = UIViewAnimationOptionTransitionCurlUp;
[UIView transitionWithView:self.view duration:0.15 options:(UIViewAnimationOptionCurveEaseInOut | curl) animations:^{
        self.storyTextView.text = text;
} completion:nil];