当使用基于块的动画的选项字段进行动画时,允许用户与视图交互是非常容易的。但在我的程序中,我使用的是CAKeyframeAnimation,而且我没有看到任何属性来设置启用的用户交互。有没有办法做到这一点?使用CAAnimation支持用户交互?
感谢,
编辑:下面是实际的代码:
- (void)move
{
CGMutablePathRef path = CGPathCreateMutable();
CGPathMoveToPoint(path, NULL, 50, 120);
for (int i = 0; i < 5; i ++)
CGPathAddLineToPoint(path, NULL, arc4random() % 320, arc4random() % 480);
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
[animation setPath:path];
[animation setDuration:10];
CFRelease(path);
[self.layer addAnimation:animation forKey:@"move"];
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[self setAlpha:0];
}
它是视图的一个属性。你应该可以在mainView中设置它。 – Legolas
Legolas,我试过了,无济于事。感谢 –
能否详细说明你想要达到的目标? – Legolas