UIView *view = [[UIView alloc]initWithFrame:CGRectMake(100,100,100,100)];
view.backgroundColor = [UIColor redColor];
[self.view addSubview:view];
上跳:
[UIView beginAnimations:@""context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationDuration:0.7f];
[UIView setAnimationRepeatCount:30];
CGPoint center = view.center;
if (center.y >40.f) {
center.y -=20;
view.center = center;
}else{
center.y +=20;
view.center = center;
}
[UIView commitAnimations];
旋转:
for(int i =0; i <100; i++){
[UIView beginAnimations:@"rotate"context:nil];
[UIView setAnimationDuration:10];
view.transform=CGAffineTransformMakeRotation((i+1)*2.0*M_PI/11.0);
[UIView commitAnimations];
}
//该程序转动100下,具体可根据需要设置,另外,重复次数不设置时默认为1