如何在UIView中使用setAnimationStartDate? [英] How to use setAnimationStartDate in the UIView?

查看:81
本文介绍了如何在UIView中使用setAnimationStartDate?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用setAnimationStartDate?
以下代码不起作用。

How to use setAnimationStartDate? The following code does not work.

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:3.0]; 
NSDate *date = [NSDate dateWithTimeIntervalSinceNow:3];
[UIView setAnimationStartDate:date];

CGPoint point = _imageView.center;
point.y += 150;
[_imageView setCenter:point];

[UIView commitAnimations];


推荐答案

您可以使用基于块的动画。它们更清洁,可以完全满足您的需求。一种查看方法是 + [UIView animateWithDuration:delay:options:animations:complete:] delay 参数在您遇到的情况中会很有用。这是一个示例。

You could use block-based animations. They are much cleaner and can do exactly what you need. One method to look at is +[UIView animateWithDuration:delay:options:animations: completion:]. The delay parameter would be useful in your situation. Here is an example.

[UIView animateWithDuration:10 
                      delay:3 
                     options:UIViewAnimationOptionCurveEaseIn 
                  animations: ^{
                                     CGPoint point = _imageView.center;
                                     point.y += 150;
                                     [_imageView setCenter:point];
                               } 
                  completion: ^(BOOL finished) {
                                     NSLog(@"Animation Complete");
                               }];

您可能不得不弄乱延迟模仿您的 NSDate 设置。

You may have to mess around with the delay to mimic your NSDate setup.

这篇关于如何在UIView中使用setAnimationStartDate?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆