我无法在任何地方找到它。所以,如果你有关于它的信息,请给我一个链接。iOS:视图控制器之间的动画
我有一个视图控制器,我做了一个简单的游戏菜单。它上面有一些按钮。 我有另一个视图控制器,也有一些按钮。
现在的问题是: “我选择一个按钮触发自定义继续(没有任何动画)到另一个视图控制器,它会运行它的按钮后,我怎么能做这个按钮的动画(隐藏屏幕)动画(从屏幕边框进入屏幕)?“
我在此是这样的:
1)理论值:使一个IBAction为用于菜单按钮,则在该IBAction为我调用一个动画制作方法,其中所说的performSegueMethod :.之后,在新的VC中,viewWillAppear方法调用动画方法(与源VC几乎相同的方法)。所有这些都有效,但这看起来并不平坦。当目标VC替换源VC时,出现此动画的问题。当所有看起来都是静态的,并且只有在这个动画开始之后,才会有一秒钟。 我不知道如何去除这个目标的VC滞后。可能是我必须在加载之前加载目标视图?我试图做到这一点,但可能是一个错误,或只是不帮助我。
2)做法:
firstViewController.m:
- (IBAction)newGameSegueButton {
[self menuSlideInDirection:@"CenterToLeft" performingSegueWithIdentifier:@"mode"];
}
-(void)menuSlideInDirection:(NSString *)direction performingSegueWithIdentifier:(NSString *)segueIdentifier
{
[UIView animateWithDuration:0.4 animations:^{
CGPoint newGameButtonCenter;
newGameButtonCenter.x = directionIndex * 160;
newGameButtonCenter.y = self.gameButtonSlide.center.y;
self.gameButtonSlide.center = newGameButtonCenter;
[UIView animateWithDuration:0.3 delay:0.1 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
//some animation too
} completion:nil];
[UIView animateWithDuration:0.2 delay:0.2 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
//animation
} completion:nil];
[UIView animateWithDuration:0.1 delay:0.3 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
//some animation too
} completion:^(BOOL finished){
if(segueIdentifier){
[self performSegueWithIdentifier:segueIdentifier sender:self];
}
}];
}];
}
好,然后自定义赛格瑞代码非常简单:
-(void)perform
{
UIViewController *src = self.sourceViewController;
UIViewController *dst = self.destinationViewController;
[src.navigationController pushViewController:dst animated:NO];
}
而且我secondViewController.m:
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self menuSlideInDirection:@"RightToCenter" performingSegueWithIdentifier:nil];
}
menuSlideInDirection:@“RightToCenter”performSegueWithIdentifier:secondViewController中的nil与firstView中具有相同名称的方法相同。
我正在寻找流畅的目标视图控制器的特定对象的动画。
可能是做错了,还有另一种方式来做到这一点? (我只想将目标VC的所有视图和所有控件添加到源VC并删除“目标VC”)。
希望有人能帮助我。
你对新视图控制器进行的segue转换是什么? –
嗯,我想我不使用任何segue过渡,你可以在我的执行方法中看到。我理解你了吗? –
你正在调用'performSegueWithIdentifier:'。这是一种推动,莫代尔?它是什么样的?再一次,这可能没有关系;我只是好奇而已。您将两个视图置于相同的VC下都是正确的,这会将整个过程置于您的控制之下,并确保您的流畅。否则,你可以做Roshan建议的黑客攻击。 –