如何在没有阴影的情况下移动(动画)制作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);
}
还是有其他更好的方法让对象移动动画?
答案 0 :(得分:7)
我会用这样的东西:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.3];
button.center = CGPointMake(x,y);
[UIView commitAnimations];