É possível animar com sucesso um UIButton em movimento?
Estou tentando animar um botão que se move pela tela. A qualquer momento, o usuário pode pressionar o botão. Mas o botão não responde aos toques. Eu tentei um bloco de animação, mas o botão simplesmente se move imediatamente para suas coordenadas finais, enquanto o quadro mostra a animação (o botão é chamado de bolha):
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:5.0];
CGAffineTransform newTransform = CGAffineTransformMakeScale(3, 3);
bubble.transform = CGAffineTransformTranslate(newTransform, 0, -460);
[UIView commitAnimations];
Então, tentei o Core Animation com a ajuda de um código de exemplo (o caminho não é importante, é apenas um exemplo):
CGMutablePathRef thePath = CGPathCreateMutable();
CGPathMoveToPoint(thePath,NULL,15.0f,15.f);
CGPathAddCurveToPoint(thePath,NULL,
15.f,250.0f,
295.0f,250.0f,
295.0f,15.0f);
CAKeyframeAnimation *theAnimation=[CAKeyframeAnimation animationWithKeyPath:@"position"];
theAnimation.path=thePath;
CAAnimationGroup *theGroup = [CAAnimationGroup animation];
theGroup.animations=[NSArray arrayWithObject:theAnimation];
theGroup.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
theGroup.duration=15.0;
CFRelease(thePath);
[bubble.layer addAnimation:theGroup forKey:@"animatePosition"];
Mas os botões ainda não respondem aos toques. Btw, eu tenho vários desses botões 'bolha' na tela ao mesmo tempo, portanto, ter vários NSTimers simultaneamente ativos não seria o ideal.
Alguém pode sugerir outra abordagem? Talvez eu deva animar o UIImageViews e torná-los repetidos em toques? Ou terei o mesmo problema? Isso está me intrigando há alguns dias, então qualquer ajuda é muito apreciada.
Obrigado :)
Michael