使用自定义segue动画替换另一个视图? [英] Displacing one view with another with a custom segue animation?
本文介绍了使用自定义segue动画替换另一个视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图实现SUBJ,但不能使目标segue出现在我的动画中。我想为视图更改做动画,新segue将取代旧的。目前我的执行方法如下:
I am trying to implement SUBJ but can't make destination segue appear in my animation. I want to make animation for view change where new segue will displace old one. Currently my perform method looks like this:
- (void) perform {
UIViewController *src = (UIViewController *) self.sourceViewController;
UIViewController *dst = (UIViewController *) self.destinationViewController;
[UIView animateWithDuration:2.0
animations:^{
//tried a lot of staff to make dst view to fall from top at the same time as current view falling to bottom but failed.
src.view.transform=CGAffineTransformMakeTranslation(0, 480);
}
completion:^(BOOL finished){
[[self sourceViewController] presentModalViewController:[self destinationViewController] animated:NO];
}
];
}
任何想法如何添加到我的动画块从顶部出现的新视图?
Any ideas how can I add to my animation block new view appearing from top?
非常感谢!
编辑:
- (void) perform {
UIViewController *src = (UIViewController *) self.sourceViewController;
UIViewController *dst = (UIViewController *) self.destinationViewController;
src.view.transform = CGAffineTransformMakeTranslation(0, 0);
dst.view.transform = CGAffineTransformMakeTranslation(0, -480);
[UIView animateWithDuration:2.0
animations:^{
[src.view addSubview:dst.view];
src.view.transform = CGAffineTransformMakeTranslation(0, 460);
}
completion:^(BOOL finished){
[src presentModalViewController:dst animated:NO];
}
];
}
这是我最后做了什么。
推荐答案
我不会得到你的意思是新的和旧的,所以我假设new = dst和old = src。
I don't quite get what you mean by new and old so i assume new = dst and old = src.
- (void) perform {
UIViewController *src = (UIViewController *) self.sourceViewController;
UIViewController *dst = (UIViewController *) self.destinationViewController;
src.view.transform = CGAffineTransformMakeTranslation(0, 0);
dst.view.transform = CGAffineTransformMakeTranslation(0, -480);
[UIView animateWithDuration:2.0
animations:^{
[src presentModalViewController:dst animated:NO];
src.view.transform = CGAffineTransformMakeTranslation(0, 480);
dst.view.transform = CGAffineTransformMakeTranslation(0, 0);
}
];
}
这样就可以了。
这篇关于使用自定义segue动画替换另一个视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文