2009-07-06 6 views
1

comment faire un UIButton lors du déplacement (animé) sans ombre? J'ai essayé le code mais ne peut pas le rendre quelqu'un peut signaler ou MODIFIER le problèmeUIButton déplacer animation problème

-(IBAction)move{ 

point=CGPointMake(0,1); 
for(int i=0;i<50;i++){ 
    NSLog(@"fdfafa"); 



    CATransition *animation = [CATransition animation]; 
    [animation setType:@"push"]; 
    [animation setSubtype:@"fromBottom"]; 
    [animation setDuration:0.5]; 
    //[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; 

    [testButton.layer addAnimation:animation forKey:kAnimationKey]; 

    testButton.center = CGPointMake(testButton.center.x, testButton.center.y + point.y); 

    } 
NSLog(@"%f",testButton.center.y); 

} 

ou avoir d'autres une meilleure méthode pour faire un mouvement d'objet animé?

Répondre

7

j'utiliser quelque chose comme ceci:

[UIView beginAnimations:nil context:nil]; 
[UIView setAnimationDuration:0.3]; 
button.center = CGPointMake(x,y); 
[UIView commitAnimations]; 
+0

ceci est pour UIView mais pas UIButton, que diriez-vous UIButton –

+0

désolé je lis mal a ce grâce –

+0

Thos sont des méthodes de classe à UIView :) – drvdijk