UIView的动画有两种实现方式:
1. 使用UIView的方法
[UIView beginAnimations:@"anib" context:nil];
[UIView setAnimationDuration:0.5];
view1.frame = fram1;
view2.frame = fram2;
view3.frame = fram3;
[UIView commitAnimations];
[UIView setAnimationDuration:0.5];
view1.frame = fram1;
view2.frame = fram2;
view3.frame = fram3;
[UIView commitAnimations];
2. 使用UIView.layer的方法
CATransition *animation = [CATransition animation];
animation.duration = 0.5f;
animation.timingFunction = UIViewAnimationCurveEaseInOut;
animation.fillMode = kCAFillModeForwards;
animation.removedOnCompletion = NO;//不能移除动画,否则ui就会还原
animation.subtype = @"fromLeft";
animation.type = @"oglFlip";
animation.endProgress = 0.2;
[view2.layer addAnimation:animation forKey:@"ani"];
animation.duration = 0.5f;
animation.timingFunction = UIViewAnimationCurveEaseInOut;
animation.fillMode = kCAFillModeForwards;
animation.removedOnCompletion = NO;//不能移除动画,否则ui就会还原
animation.subtype = @"fromLeft";
animation.type = @"oglFlip";
animation.endProgress = 0.2;
[view2.layer addAnimation:animation forKey:@"ani"];
最后顺带定时器的 使用:
[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(initPic1) userInfo:nil repeats:NO];