我的情况:
我有一个 UIButton
,它使用 CAKeyframeAnimation
进行动画处理,在 UIView
上声明为一个类别:
CAKeyframeAnimation * scale = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
scale.duration = duration;
scale.beginTime = delay;
scale.fillMode = kCAFillModeForwards;
NSMutableArray * times = [[NSMutableArray alloc] init];
scale.values = values;
scale.timingFunctions = times;
CAAnimationGroup * group = [CAAnimationGroup animation];
[group setDelegate:self];
[group setDuration:duration + delay];
[group setFillMode:kCAFillModeForwards];
[group setRemovedOnCompletion:NO];
[group setAnimations:[NSArray arrayWithObject:scale]];
[self.layer addAnimation:group forKey:@"scale"];
问题是在动画之后,按钮没有接收到触摸。如果我删除动画一切正常。 有谁知道我做错了什么?
谢谢
最佳答案
您不应该使用 kCAFillModeForwards 和 removedOnCompletion = NO 将动画层固定在最终位置。这不适用于控件,并会导致您注意到的行为。
相反,在将动画添加到它的层之前设置按钮的最终状态。
self.layer.transform = CGAffineTransformMakeScale(finalScaleX, finalScaleY);
[self.layer addAnimation:group forKey:@"scale"];
关于ios - UIButton 在 CAKeyframeAnimation 之后没有收到触摸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13107690/