0
我正在開發輪盤應用程序。其中,如果我點擊中心按鈕輪應旋轉幾秒鐘,然後其速度應逐漸減慢。如果有人知道,請以正確的方式引導我。如何逐漸減慢旋轉動畫
我能夠以一定的速度旋轉imageView
,但我正在努力逐漸減慢車輪的速度。
輪換代碼
CALayer *layer = container.layer; CAKeyframeAnimation *animation; animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation.z"]; animation.duration = 1.5f; animation.cumulative = YES; animation.repeatCount = 1; animation.values = [NSArray arrayWithObjects: // i.e., Rotation values for the 3 keyframes, in RADIANS [NSNumber numberWithFloat:0.0 * M_PI], [NSNumber numberWithFloat:0.75 * M_PI], [NSNumber numberWithFloat:1.5 * M_PI], nil]; animation.keyTimes = [NSArray arrayWithObjects: // Relative timing values for the 3 keyframes [NSNumber numberWithFloat:0], [NSNumber numberWithFloat:.5], [NSNumber numberWithFloat:1.0], nil]; animation.timingFunctions = [NSArray arrayWithObjects: [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn], // from keyframe 1 to keyframe 2 [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut], nil]; // from keyframe 2 to keyframe 3 animation.removedOnCompletion = NO; animation.fillMode = kCAFillModeForwards; [layer addAnimation:animation forKey:nil];
感謝您的答覆。是否有任何示例代碼來應用timingFunctions – thavasidurai