我使用此代码进行上下查看。
-(void)timeSpanAnimation{
const float movementDuration = 0.3f; // tweak as needed
int movement = (isDown ? -movementDistance : movementDistance);
isDown = (isDown ? false : true);
[UIView beginAnimations: nil context: nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationBeginsFromCurrentState: YES];
[UIView setAnimationDuration: movementDuration];
[UIView setAnimationDelegate:self];
self.frameDown.frame = CGRectOffset(self.frameDown.frame, 0, movement);
[self.frameDown setNeedsDisplay];
[UIView commitAnimations];
}
我在会话开始时(向下看)和会话结束时(向上看)调用此函数。
这项工作做得很好,但是当我改变时间(从iPhone今天到明天的更改时间)或第二天更改时间时,视图不会下降。
感谢。
更新 更改为基于块的动画,当时间更改时仍然有Bug。
-(void)timeSpanAnimation{
const float movementDuration = 0.3f; // tweak as needed
int movement = (isDown ? -movementDistance : movementDistance);
isDown = (isDown ? false : true);
[UIView animateWithDuration:movementDuration
delay:0.0f
options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut
animations:^{
self.frameDown.frame = CGRectOffset(self.frameDown.frame, 0, movement);
}
completion:nil];
}