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放在其末尾位置。
我該如何解決這個顯示故障?