您的位置:首页 > 产品设计 > UI/UE

UIView 之 Animation 一边上跳 一边旋转

2015-11-05 14:52 274 查看
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];

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: