开发者

How to animate(move) a UIButton, keeping it touchable during the move?

开发者 https://www.devze.com 2023-01-30 14:37 出处:网络
It seems that when you animate a UIButton, the real button is always at the destination position.Animation is just a \"movie\".

It seems that when you animate a UIButton, the real button is always at the destination position. Animation is just a "movie". In this code, while in the animation, the button gets the event only if i touch the empty final destination (centered at 600x900). If I touch it as i see it in the showing position, meaning at some point where the button is being drawn (in the middle of the animation) it gets nothing.

CGPoint point;
point开发者_如何学运维.x = 600;
point.y = 900;
[UIView animateWithDuration:16 
        delay:0 
        options:(UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionAllowAnimatedContent)
        animations:^{

            [movingbutton setCenter:point];
        }
        completion:^(BOOL finished){
            NSLog(@"animation completed");
        }
];

Cant figure out how to make the animating button touchable in the correct animation path. Any idea? Thanx!


Simply use an NSTimer, and manually move it (change the frame) a few pixels each step.

Is ok for you?

0

精彩评论

暂无评论...
验证码 换一张
取 消