[英]Storyboard Segue Transition Effects
第一次海報,長期觀察員。
我正在為目前正在使用的應用程序使用故事板,並且需要進行更多的過渡,而不僅僅是前進,尤其是回溯。 每當我使用此命令我都需要返回菜單時,單擊的下一個按鈕將轉到另一個ViewController,將使整個應用程序崩潰!
不知道發生了什么,我在實現文件中使用它
#import "SlideLeftSegue.h"
@implementation SlideLeftSegue
- (void)perform{
UIView *sv = ((UIViewController *)self.sourceViewController).view;
UIView *dv = ((UIViewController *)self.destinationViewController).view;
UIWindow *window = [[[UIApplication sharedApplication] delegate] window];
dv.center = CGPointMake(sv.center.x - sv.frame.size.width, dv.center.y);
[window insertSubview:dv belowSubview:sv];
[UIView animateWithDuration:0.4
animations:^{
dv.center = CGPointMake(sv.center.x,
dv.center.y);
sv.center = CGPointMake(sv.center.x + sv.frame.size.width,
dv.center.y);
}
completion:^(BOOL finished){
[[self destinationViewController]
dismissViewControllerAnimated:NO completion:nil];
}];
}
@end
這是我的頭文件
#import <UIKit/UIKit.h>
// Move to the previous screen with slide animation.
@interface SlideLeftSegue : UIStoryboardSegue
@end
我仍在學習,因此,如果您有任何想法,請多多指教。
您可以用更少的代碼來實現
呈現視圖控制器:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *view = [storyboard instantiateViewControllerWithIdentifier:@"ViewID"];
view.modalTransitionStyle = UIModalTransitionStyleCoverVertical; // you can try the other 3 UIModalTransitionStyle too
[self presentViewController:view animated:YES completion:nil];
回去:
[self dismissViewControllerAnimated:YES completion:nil];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.