UIView的动画
一種方法是利用封裝了CATransition的UIView類方法來(lái)實(shí)現(xiàn),這方法簡(jiǎn)單但效果少。
//把子視圖從父視圖里刪除的動(dòng)畫效果[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,復(fù)雜點(diǎn)但效果多些,可控性強(qiáng),推薦.
//子視圖從父視圖里刪除的動(dòng)畫效果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];
?
再傳送兩個(gè)網(wǎng)址,講的詳細(xì)些:
CATransition的動(dòng)畫效果類型及實(shí)現(xiàn)方法
UIView動(dòng)畫小記
總結(jié)
- 上一篇: 使用ganglia监控hadoop
- 下一篇: wordpress如何设置文章置顶以及区