我有这个按钮并应用这个动画。 问题是在动画之后,按钮似乎被禁用。 该按钮位于UIView中,但其位置是固定的,不明白为什么它被禁用。
CABasicAnimation *alphaAnimation;
alphaAnimation=[CABasicAnimation animationWithKeyPath:@"opacity"];
alphaAnimation.duration=0.5;
alphaAnimation.repeatCount=1;
alphaAnimation.autoreverses=NO;
alphaAnimation.fromValue=[NSNumber numberWithFloat:0.0];
alphaAnimation.toValue=[NSNumber numberWithFloat:1.0];
CAKeyframeAnimation *pulseAnimation;
pulseAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
pulseAnimation.duration = 0.5;
pulseAnimation.repeatCount = 1;
pulseAnimation.values = [NSArray arrayWithObjects:
[NSNumber numberWithFloat:0.5],
[NSNumber numberWithFloat:1.2],
[NSNumber numberWithFloat:1.0], nil];
pulseAnimation.keyTimes = [NSArray arrayWithObjects:
[NSNumber numberWithFloat:0],
[NSNumber numberWithFloat:0.5],
[NSNumber numberWithFloat:1.0], nil];
pulseAnimation.timingFunctions = [NSArray arrayWithObjects:
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn], // from keyframe 1 to keyframe 2
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut], nil]; // from keyframe 2 to keyframe 3
pulseAnimation.removedOnCompletion = NO;
pulseAnimation.fillMode = kCAFillModeForwards;
CAAnimationGroup *nearbyAnimation = [CAAnimationGroup animation];
[nearbyAnimation setAnimations:[NSArray arrayWithObjects:pulseAnimation, alphaAnimation, nil]];
[nearbyAnimation setDuration:0.5];
[nearbyAnimation setBeginTime:0.0];
[nearbyAnimation setRemovedOnCompletion:NO];
[nearbyAnimation setFillMode:kCAFillModeForwards];
[nearbyButton.layer addAnimation:nearbyAnimation forKey:nil];
由于