3
我遇到了CAKeyframeAnimation的这个问题。动画UIView的图层后,我想定位UIView到我动画的位置,以便用户可以继续使用此UIView上的按钮。在CAKeyframeAnimation后定位UIView导致显示故障
我目前使用此代码:
// Open animation
CAKeyframeAnimation *openAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.translation.y"];
openAnimation.fillMode = kCAFillModeForwards;
openAnimation.duration = .55;
openAnimation.delegate = self;
openAnimation.removedOnCompletion = NO;
openAnimation.values = [NSArray arrayWithObjects:
[NSNumber numberWithFloat:0.0],
[NSNumber numberWithFloat:58.0],
[NSNumber numberWithFloat:48.0], nil];
openAnimation.keyTimes = [NSArray arrayWithObjects:
[NSNumber numberWithFloat:0.0],
[NSNumber numberWithFloat:0.62],
[NSNumber numberWithFloat:1.0], nil];
openAnimation.timingFunctions = [NSArray arrayWithObjects:
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut], nil];
[locationView.layer addAnimation:openAnimation forKey:@"OPEN_ANIMATION"];
和委托方法:
- (void)animationDidStop:(CAKeyframeAnimation *)anim finished:(BOOL)flag
{
locationView.y = -10.0;
}
这实际工作,但最后我有在动画被移除了这个显示故障(UIView图层跳回到原始位置)并立即调用委托方法,这会使其跳转到结束位置。
我觉得最后的过程如下:动画完成,渲染动画的最后一帧,跳回到原始位置,渲染此帧,调用委托方法并将uiview放在其末尾位置。
我该如何解决这个显示故障?