gpt4 book ai didi

ios - UIView 页面 curl 动画不适用于 block

转载 作者:行者123 更新时间:2023-11-28 19:45:25 24 4
gpt4 key购买 nike

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

这按预期工作

[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
}
}];

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

最佳答案

你会想要尝试 UIViewtransitionWithView 来代替:

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

关于ios - UIView 页面 curl 动画不适用于 block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32530907/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com