在iOS中动画时,按钮上的用户交互

时间:2012-07-18 10:17:02

标签: objective-c ios animation button

我正在以编程方式创建按钮,它们是动画的(淡入淡出和移动),我需要按钮仍然可以进行用户交互。我尝试过像

这样的事情

选项:(UIViewAnimationOptionAllowUserInteraction

似乎什么都不做:/我在这里阅读了几篇不同建议的帖子,包括有人说这实际上是不可能的。有人知道我是否可以在按钮动画时启用用户交互,如果不可能,人们如何解决这个问题呢?

谢谢。

这是我当前使用的动画代码:

[UIView animateWithDuration:106 
                      delay:0 
                    options:(UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionAllowAnimatedContent | UIViewAnimationOptionCurveEaseInOut)
                 animations:^{


                     [_planetButton setCenter:point];
                     _planetButton.alpha = 0.2;
                     _planetButton.userInteractionEnabled = YES;


                 }
                 completion:^(BOOL finished){
                     NSLog(@"animation completed");
                     //[_planetButton removeFromSuperview];
                 }
 ];

我也尝试了动画,例如:

    CABasicAnimation *move = [CABasicAnimation animationWithKeyPath:@"transform2"]; 
    move.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    move.duration = 5.105;
    move.repeatCount = 1;
    move.autoreverses = YES;
    move.removedOnCompletion = YES;
    move.toValue = [NSValue valueWithCGPoint:point];
    [_planetButton.layer addAnimation:move forKey:nil];

0 个答案:

没有答案