UIView的动画
一種方法是利用封裝了CATransition的UIView類方法來實現,這方法簡單但效果少。
//把子視圖從父視圖里刪除的動畫效果[UIView beginAnimations:@"animation_" context:nil];
[UIView setAnimationDuration:1.25];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
UIViewController * coming = [[UIViewController alloc] init];
UIViewController * going = [[UIViewController alloc] init];
coming.view = self.view.superview;
going.view = self.view;
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view.superview cache:YES];
[coming viewWillAppear:YES];
[going viewWillDisappear:YES];
[going.view removeFromSuperview];
[going viewDidDisappear:YES];
[coming viewDidAppear:YES];
[UIView commitAnimations];
[coming release];
[going release];
另一種方法是直接利用CATransition,復雜點但效果多些,可控性強,推薦.
//子視圖從父視圖里刪除的動畫效果CATransition * animation = [CATransition animation];
[animation setRemovedOnCompletion:NO];
[animation setDuration:.25];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromRight];
UIViewController * coming = [[UIViewController alloc] init];
UIViewController * going = [[UIViewController alloc] init];
coming.view = self.view.superview;
going.view = self.view;
[self.view.superview.layer addAnimation:animation forKey:@"animation_"];
[coming viewWillAppear:YES];
[going viewWillDisappear:YES];
[going.view removeFromSuperview];
[going viewDidDisappear:YES];
[coming viewDidAppear:YES];
[self.view.superview.layer removeAnimationForKey:@"animation_"];
[coming release];
[going release];
?
再傳送兩個網址,講的詳細些:
CATransition的動畫效果類型及實現方法
UIView動畫小記
總結
- 上一篇: 使用ganglia监控hadoop
- 下一篇: wordpress如何设置文章置顶以及区