我在Xcode项目中创建了一个自定义segue,它反映了内置的push segue:我的segue从左侧而不是右侧引入了另一个UIViewController
。然而,我的问题是,我如何设法完成"放松"这个segue?
我知道仅仅做一个unwindToViewController
类型的segue是行不通的,因为我正在做一个自定义的segue。所以我不太确定从哪里开始。这是我在下面的segue代码
LeftToRightSegue.h
#import <UIKit/UIKit.h>
@interface LeftToRightSegue : UIStoryboardSegue
@property CGRect animationFrame;
@property CGRect sideFrame;
@end
LeftToRightSegue.m
#import "LeftToRightSegue.h"
@implementation LeftToRightSegue
- (void)perform{
UIViewController *sourceVC = self.sourceViewController;
UIViewController *destinationVC = self.destinationViewController;
CGRect sideFrame = destinationVC.view.frame;
[destinationVC.view setFrame: CGRectMake(-(sourceVC.view.frame.size.width), 0, sourceVC.view.frame.size.width/2, sourceVC.view.frame.size.height)];
CGRect animationFrame = sourceVC.view.frame;
sideFrame = destinationVC.view.frame;
animationFrame.size.width = sourceVC.view.frame.size.width;
destinationVC.view.alpha = 0;
[[sourceVC.view superview]addSubview:destinationVC.view];
[UIView animateWithDuration:0.3
delay:0.0
options:UIViewAnimationOptionCurveEaseOut
animations:^{
destinationVC.view.frame = animationFrame;
destinationVC.view.alpha = 1;
}
completion:^(BOOL finished) {
destinationVC.view.alpha = 1;
destinationVC.view.frame = animationFrame;
}];
}
@end
如果有人可以帮助我从这个segue(自定义放松)倒退,我将非常感激。我试图做同样的动画,但倒退但我一直收到错误 - 不知道为什么它不会工作。如果有人建议执行这种类型的segue,请随时告诉我。谢谢!