Ios 链接动画:第一个是即时动画
以下功能应为A.使视图变大B.等待5秒,C.再次缩小视图。问题是,一个错误不是在两秒钟内发生的,而是在瞬间发生的Ios 链接动画:第一个是即时动画,ios,animation,uiviewanimation,Ios,Animation,Uiviewanimation,以下功能应为A.使视图变大B.等待5秒,C.再次缩小视图。问题是,一个错误不是在两秒钟内发生的,而是在瞬间发生的 - (void) showAndHide { CGRect r = self.frame; float right = r.origin.x + r.size.width, h = r.size.height, y = r.origin.y; [UIView animateWithDuration:2 delay:0
- (void) showAndHide {
CGRect r = self.frame;
float right = r.origin.x + r.size.width, h = r.size.height, y = r.origin.y;
[UIView animateWithDuration:2
delay:0
options:UIViewAnimationOptionCurveEaseInOut|UIViewAnimationOptionAllowUserInteraction
animations:^{
self.frame = CGRectMake(right - 400, y, 400, h);
[UIView animateWithDuration:2
delay:5
options: UIViewAnimationOptionOverrideInheritedCurve |
UIViewAnimationOptionCurveLinear |
UIViewAnimationOptionOverrideInheritedDuration
animations:^{
self.frame = CGRectMake(right - 40, y, 40, h);
}
completion:nil];
}
completion:nil];
}
这可能是什么原因造成的?提前谢谢 将第二个动画放入第一个动画的完成处理程序中:
- (void) showAndHide {
CGRect r = self.frame;
float right = r.origin.x + r.size.width, h = r.size.height, y = r.origin.y;
[UIView animateWithDuration:2
delay:0
options:UIViewAnimationOptionCurveEaseInOut|UIViewAnimationOptionAllowUserInteraction
animations:^{
self.frame = CGRectMake(right - 400, y, 400, h);
}
completion:^{
[UIView animateWithDuration:2
delay:5
options: UIViewAnimationOptionOverrideInheritedCurve | UIViewAnimationOptionCurveLinear | UIViewAnimationOptionOverrideInheritedDuration
animations:^{
self.frame = CGRectMake(right - 40, y, 40, h);
}
completion:NULL];
}];
}
您的方法的问题是,两个动画同时排队。如果您想继续使用代码,我认为在第二个动画的选项中添加UIViewAnimationOptionBeginFromCurrentState
也可以解决您的问题。不过我不太确定