引用了一本国外编程书上的代码:
#import <UIKit/UIKit.h>
@interface CustomSegue : UIStoryboardSegue
@end
#import "CustomSegue.h"
@implementation CustomSegue
- (void)perform{
UIViewController *src = (UIViewController *)self.sourceViewController;
UIViewController *dest = (UIViewController *)self.destinationViewController;
CGRect f = src.view.frame;
CGRect originalSourceRect = src.view.frame;
f.origin.y = f.size.height;
[UIView animateWithDuration:0.3 animations:^{
src.view.frame = f;
} completion:^(BOOL finished) {
src.view.alpha = 0;
dest.view.frame = f;
dest.view.alpha = 0;
[[src.view superview] addSubview:dest.view];
[UIView animateWithDuration:0.3 animations:^{
dest.view.frame = originalSourceRect;
dest.view.alpha = 1.0f;
} completion:^(BOOL finished) {
[dest.view removeFromSuperview];
src.view.alpha = 1.0;
[src.navigationController pushViewController:dest animated:NO];
}];
}];
}
@end
问题是,回退的时候还是pop的动画,那么怎么能让动画和push时的自定义动画正好相反呢?