我想在使用自定義的segue的UIViewControllers之間添加一個簡單的推動畫。沒有UINavigationController的Push Segue動畫
(無需轉換我的控制器使用一個UINavigationController)不使用導航控制器時
迄今爲止發現的正常工作與導航控制器的答案,但失敗。 (我還在讀書,並試圖其他答案我在這裏看到的堆棧溢出)
我定製SEGUE .M感謝(ZHCustomSegue.m)扎基爾在12年7月5日
#import "SFCustomSegue.h"
#import "QuartzCore/QuartzCore.h"
@implementation SFCustomSegue
-(void)perform {
UIViewController *sourceViewController = (UIViewController*)[self sourceViewController];
UIViewController *destinationController = (UIViewController*)[self destinationViewController];
CATransition* transition = [CATransition animation];
transition.duration = 4.0;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromRight;
[sourceViewController.view.layer addAnimation:transition forKey:kCATransition];
[sourceViewController presentViewController:[self destinationViewController] animated:NO completion:nil];
}
如果我使用的是導航控制器按扎基爾原來的例子,取而代之的最後兩行:
[sourceViewController.navigationController.view.layer addAnimation:transition
forKey:kCATransition];
[sourceViewController.navigationController pushViewController:destinationController animated:NO];
工程....
蘋果的醫生說(通知不是導航控制器,並採用AM odal segue):
- (void)perform
{
// Add your own animation code here.
[[self sourceViewController] presentModalViewController:[self destinationViewController] animated:NO];
}
通過不工作,我沒有得到動畫。在Zakir的代碼中,使用4.0秒需要4.0秒,並且獲得我想要的動畫。當然,如果我使用導航控制器,推送轉換是默認的。在這段代碼中,我沒有獲得動畫,它需要0秒。
有沒有人得到自定義segue動畫來使用UIViewControllers?
如果有人可以重寫這個來使用完成塊,我希望更好,但這是有效的。 –