1
我正在研究和iPhone应用程序,并且有手势识别器的问题。转换图层上的UIGestureRecognizer
我在视图中添加了UITapGestureRecognizer,然后使用CABasicAnimation转换与此视图相关的图层。在此转换之后,手势识别器只能在转换之前的视图占用的区域中工作。
希望我的问题,这一点说明是可以理解的..
下面是一些代码:
UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(myViewTapped:)];
[self.myView addGestureRecognizer:tapGestureRecognizer];
CABasicAnimation * animation = [CABasicAnimation animationWithKeyPath:@"position.y"];
[animation setFromValue:[NSNumber numberWithFloat:0]];
[animation setToValue:[NSNumber numberWithFloat: - 100]];
[animation setDuration:.3];
[animation setTimingFunction:[CAMediaTimingFunction functionWithControlPoints:.55 :-0.25 :.30 :1.4]];
animation.additive = YES;
animation.removedOnCompletion = NO;
animation.fillMode = kCAFillModeForwards;
[self.myView.layer addAnimation:animation forKey:nil];
我如何处理这个问题?
谢谢!
感谢你的帮助,我 不能使用基于UIView的动画,因为我不得不使用自定义缓动曲线(你知道一种方法来做到这一点吗?) 我终于找到了这个解决方案: 我将ViewController设置为CABasicAnimation的委托,删除了additive属性,然后在animationDidStop方法中,我添加以下代码行: self.bottomView.layer.position = CGPointMake(self.bottomView.layer.position.x,[((NSNumber *)((CABasicAnimation *)anim).toValue)floatValue]); - 我知道如果有人有一个更好的解决方案 – hugo 2013-04-10 13:23:30