Trả lời

46

Hãy thử điều này:

UIViewController *yourViewController = [[UIViewController alloc]init]; 

[UIView beginAnimations: @"Showinfo"context: nil]; 
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut]; 
[UIView setAnimationDuration:0.75]; 
[self.navigationController pushViewController: yourViewController animated:NO]; 
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO]; 
[UIView commitAnimations]; 
+0

Cảm ơn! Điều này thực sự thực sự hữu ích! –

+1

ví dụ điển hình, điều này sẽ giúp nhiều người trong chúng ta, thnks xCode :) –

+1

Bất kỳ ý tưởng nào về cách thực hiện việc này với quá trình chuyển đổi kiểu iOS 8? – SleepsOnNewspapers

0

Bạn nên cân nhắc làm điều gì đó như:

ViewController *myVC = [[ViewController alloc] initWithFrame:OFF_SCREEN]; 
[navigationController pushViewController:myVC animated:NO]; 

nơi OFF_SCREEN là một số CGRect bên dưới màn hình, tương tự (0, 481, 320, 480). Sau đó, sử dụng khối hoạt ảnh để điều chỉnh khung nhìn của viewcontroller's view.origin thành (0, 0). Bạn có thể muốn làm khối animate trong viewDidLoad hoặc viewDidAppear.

+0

bộ điều khiển chế độ xem không có 'initWithFrame:' ​​initializer –

54

Nếu bạn muốn một hình ảnh động mờ dần, phương pháp này hoạt động.

CATransition* transition = [CATransition animation]; 
transition.duration = 0.3; 
transition.type = kCATransitionFade; 
transition.subtype = kCATransitionFromTop; 

[self.navigationController.view.layer addAnimation:transition forKey:kCATransition]; 
[self.navigationController pushViewController:gridController animated:NO]; 
+1

Làm việc như một nhà vô địch! Chuyển đổi đẹp. Cảm ơn! –

+0

Hey đã làm việc tuyệt vời cho tôi, cảm ơn rất nhiều !!! –

+0

Hoạt động đẹp mắt! Cảm ơn rất nhiều! – Amit

21

Đối với hiển thị hình ảnh động PushViewConttroler như hiện dưới đây đang làm việc,

Đối Đẩy

ViewController *VC = [self.storyboard instantiateViewControllerWithIdentifier:@"ViewController"]; 
CATransition* transition = [CATransition animation]; 
transition.duration = 0.4f; 
transition.type = kCATransitionMoveIn; 
transition.subtype = kCATransitionFromTop; 
[self.navigationController.view.layer addAnimation:transition 
                forKey:kCATransition]; 
[self.navigationController pushViewController:VC animated:NO]; 

Và đối với POP

CATransition* transition = [CATransition animation]; 
transition.duration = 0.4f; 
transition.type = kCATransitionReveal; 
transition.subtype = kCATransitionFromBottom; 
[self.navigationController.view.layer addAnimation:transition 
              forKey:kCATransition]; 
[self.navigationController popViewControllerAnimated:NO]; 

Có 1 vấn đề tho ugh, đó là màn hình hiển thị màu đen nhạt của nó khi nó đi lên/xuống,
Làm việc trên đó, Ngay sau khi nó được thực hiện bài mới mã ở đây.

+3

Ngoài việc đẩy bạn cũng đã thêm cửa sổ bật lên. Điểm tốt! –

+0

Nhưng vẫn không có đường cong hoạt hình ... –

+0

@Julian, Không nhận được điểm của bạn. – Dilip

Các vấn đề liên quan