簡體   English   中英

目標C-自定義情節提要Segue黑屏

[英]Objective C - Custom Storyboard Segue Black Screen

我有一個自定義情節提要segue,可顯示從右到左的視圖。 但是在動畫過程中,會顯示一個短暫的黑屏,這會給您帶來鋸齒狀的體驗。

這是我的代碼:

    UIViewController *srcViewController = (UIViewController *) self.sourceViewController;
    srcViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
    UIViewController *destViewController = (UIViewController *) self.destinationViewController;

    CATransition *transition = [CATransition animation];
    transition.duration = 0.1;
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    transition.type = kCATransitionPush;
    transition.subtype = kCATransitionFromRight;
    [srcViewController.view.window.layer addAnimation:transition forKey:nil];

    [srcViewController presentViewController:destViewController animated:NO completion:nil];

確保您的destViewController在viewDidLoad中將其視圖的背景色設置為某種顏色:

//DestViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
}

或者,我不確定100%是否可行,但是我更適合您的代碼:

UIViewController *destViewController = (UIViewController *)self.destinationViewController;
destViewController.view.backgroundColor = [UIColor whiteColor];

//Now do all the CATransitions, etc.

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM