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];
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");
}];
You may have to mess around with the delay
to mimic your NSDate
setup.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.