UIView翻页动画与块不起作用

3
我正在尝试将已有的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个回答

7
你可以尝试使用 UIViewtransitionWithView 方法替代它:
UIViewAnimationOptions curl = UIViewAnimationOptionTransitionCurlUp;
[UIView transitionWithView:self.view duration:0.15 options:(UIViewAnimationOptionCurveEaseInOut | curl) animations:^{
        self.storyTextView.text = text;
} completion:nil];

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接