【问题标题】:UIView page curl animations isn't working with blocksUIView 页面卷曲动画不适用于块
【发布时间】:2015-09-11 19:33:18
【问题描述】:

我正在尝试将工作 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 不会影响即时过渡,它只是在延迟后运行完成块。

【问题讨论】:

    标签: ios objective-c animation uiview uiviewanimation


    【解决方案1】:

    你会想试试UIViewtransitionWithView

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-03-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多