在做动画的控件不触发手势事件问题及解决方案
在做动画的控件不触发手势事件问题及解决方案
[UIView beginAnimations:@"Marquee" context:NULL]; //动画时长 [UIView setAnimationDuration:2.0]; //动画节奏 [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut|UIViewAnimationOptionAllowUserInteraction]; //重复次数 [UIView setAnimationRepeatCount:1]; self.decribeImageView.alpha = 1.0; self.describeTitleLabel.alpha = 1.0; [UIView animateKeyframesWithDuration: 5.0 delay: 0 options: UIViewKeyframeAnimationOptionCalculationModeLinear|UIViewKeyframeAnimationOptionAllowUserInteraction animations: ^{ self.decribeImageView.frame = CGRectMake(self.decribeImageViewEdge+FULL_WIDTH, self.decribeImageViewTop, SCREEN_WIDTH -self.decribeImageViewEdge*2, self.decribeImageViewHeight*FULL_WIDTH/375); [UIView addKeyframeWithRelativeStartTime: 0 relativeDuration: 1.0/(5*4) animations: ^{ self.decribeImageView.frame = CGRectMake(self.decribeImageViewEdge, self.decribeImageViewTop, SCREEN_WIDTH -self.decribeImageViewEdge*2, self.decribeImageViewHeight*FULL_WIDTH/375); }]; [UIView addKeyframeWithRelativeStartTime: (1 - 1.0/(5*4) - 0.001) relativeDuration: 1.0/(5*4) animations: ^{ self.decribeImageView.frame = CGRectMake(-self.decribeImageViewEdge-FULL_WIDTH, self.decribeImageViewTop, SCREEN_WIDTH -self.decribeImageViewEdge*2, self.decribeImageViewHeight*FULL_WIDTH/375); }]; [UIView addKeyframeWithRelativeStartTime: (1 - 0.001) relativeDuration:0.001 animations: ^{ self.decribeImageView.alpha = 0; self.describeTitleLabel.alpha = 0; }]; } completion:^(BOOL finished) { [self removeFromSuperview]; }]; CAAnimationGroup *group = [[CAAnimationGroup alloc] init]; CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"]; animation.values = @[@0.0, @1.0, @1.0]; animation.keyTimes = @[[NSNumber numberWithFloat:0.0], [NSNumber numberWithFloat:0.5], [NSNumber numberWithFloat:1.0]]; CAKeyframeAnimation * opacityAnimation = [CAKeyframeAnimation animation]; opacityAnimation.keyPath = @"opacity"; opacityAnimation.values = @[@0.0, @1.0]; group.animations = @[animation, opacityAnimation]; group.duration = 2.0; group.delegate = self; group.repeatCount = 1.0; group.removedOnCompletion = NO; group.fillMode = kCAFillModeForwards; group.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]; [self.diceAnimatedImageView.layer addAnimation:group forKey:@"diceAnimatedImageViewAnimation"];
若还不行就在动画控件上增加一个透明按钮,添加按钮事件。
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~