2011-10-09 86 views
0

我正在嘗試切換視圖,但我希望動畫與視圖擡起並像一張紙摺疊以查看底下是什麼。iPhone查看動畫

任何教程或如何獲得該視圖動畫的例子,如果它是一個動畫,將不勝感激。

實際上,當您點擊角落上的按鈕時,地圖應用使用的視圖。

回答

2

像這樣的東西應該工作:

MyViewController *myView = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil]; 
myView.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissModalViewControllerAnimated:)] autorelease]; 
UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:myView]; 
navigation.modalTransitionStyle = UIModalTransitionStylePartialCurl; 
navigation.delegate = self; 
[self presentModalViewController:navigation animated:YES]; 

這裏的關鍵是在呈現模態視圖之前,需要將10個屬性設置爲UIModalTransitionStylePartialCurl

此處瞭解詳情:UIViewController Class Reference(找modalPresentationStylemodalTransitionStylepresentModalViewController:animated:dismissModalViewControllerAnimated:)。

+0

+1 - 不錯的樣本。 – bryanmac

1

這樣做有兩種基本方式,舊的是不再推薦:

[UIView beginAnimations:nil context:nil]; 
[UIView setAnimationDuration:0.5]; 
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown 
            forView:containerView cache:YES]; 

[containerView addSubview:subview]; 

[UIView commitAnimations]; 

,而新的(它使用從iOS 4的支持和塊):

[UIView transitionWithView:containerView duration:0.5 
    options:UIViewAnimationOptionTransitionCurlDown 
    animations:^ { [containerView addSubview:subview]; } 
    completion:nil]; 
+0

雖然這可能在理論上回答這個問題,但[這將是更可取的](http://meta.stackexchange.com/q/8259)在這裏包含答案的重要部分,並提供供參考的鏈接。 –

+0

「轉到本頁面(可以改變,或完全消失,只要有第三方感覺)」不是答案。總結/釋義在這裏。 – cHao

+0

@ B蜥蜴你完全正確,編輯即將到來。 –