IPhone開發(fā)應(yīng)用界面跳轉(zhuǎn)實現(xiàn)UIView動畫
IPhone開發(fā)應(yīng)用界面跳轉(zhuǎn)實現(xiàn)UIView動畫是本文要結(jié)束的內(nèi)容,主要是來學習如何實現(xiàn)動畫效果的內(nèi)容,不多說,來看詳細內(nèi)容講解。
在界面的跳轉(zhuǎn)有兩種方法,一種方法是先刪除原來的界面,然后在插入新的界面:如下代碼
- if (self.rootViewController.view.superview == nil) {
- [singleDollController.view removeFromSuperview];
- [self.view insertSubview:rootViewController.view atIndex:0];
- }
- else {
- [rootViewController.view removeFromSuperview];
- [self.view insertSubview:singleDollController.view atIndex:0];
- }
使用這種方式無法實現(xiàn)界面跳轉(zhuǎn)時的動畫效果。
另一中方式為將跳轉(zhuǎn)的界面的Controller放入到UINavigationController中,使用push或pop實現(xiàn)跳轉(zhuǎn):使用這種方式可用實現(xiàn)動畫效果
- navController = [[UINavigationController alloc]init];
- [navController setNavigationBarHidden:YES];
- [window addSubview:navController.view];
- rootView = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
- [navController pushViewController:rootView animated:NO];
- ///
- self.singleDollView = view;
- [UIView beginAnimations:nil context:NULL];
- [UIView setAnimationDuration:0.5];
- [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navController.view cache:NO];
- [self.navController pushViewController:self.singleDollView animated:NO];
- [UIView commitAnimations];
小結(jié):IPhone開發(fā)應(yīng)用界面跳轉(zhuǎn)實現(xiàn)UIView動畫的內(nèi)容介紹完了,希望本文對你有所幫助!更多關(guān)于iphone開發(fā)的相關(guān)內(nèi)容經(jīng)參考iphone開發(fā)頻道。