UIButton移动动画问题

时间:2009-07-06 09:24:54

标签: iphone

如何在没有阴影的情况下移动(动画)制作UIButton?我尝试了代码,但无法让某人修改或指出问题

-(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);

}

还是有其他更好的方法让对象移动动画?

1 个答案:

答案 0 :(得分:7)

我会用这样的东西:

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