如何在UIView中使用setAnimationStartDate?

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

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

你可以使用基于块的animation。 他们更清洁,可以做你所需要的。 看一个方法是+[UIView animateWithDuration:delay:options:animations: completion:]delay参数在您的情况下会很有用。 这是一个例子。

 [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 delay来模仿你的NSDate设置。