Presenting a view controller with transparency and animation

前端 未结 2 1542
没有蜡笔的小新
没有蜡笔的小新 2021-01-12 11:07

I\'m setting self.window.rootViewController.modalPresentationStyle = UIModalPresentationCurrentContext; in my Application Delegate so that I can present a view

相关标签:
2条回答
  • 2021-01-12 11:48

    I ended up doing this:

    AppDelegate *appDelegate = [AppDelegate sharedAppDelegate];
    
    // Set the root VC modal presentation style
    appDelegate.window.rootViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
    
    WalkthroughViewController *walkthroughVC = [[WalkthroughViewController alloc] initWithNibName:nil bundle:nil];
    
    [self presentViewController:walkthroughVC animated:NO completion:nil];
    
    // Manually animate the view
    walkthroughVC.view.alpha = 0;
    [UIView animateWithDuration:0.5 animations:^{
           walkthroughVC.view.alpha = 1;
    }];
    
    // Reset root VC modal presentation style 
    appDelegate.window.rootViewController.modalPresentationStyle = UIModalPresentationFullScreen;
    
    0 讨论(0)
  • 2021-01-12 11:56

    You could use a containment view that exists in the base view controller. Instead of presenting a modal, animate the positioning of the containment view up to simulate a modal presentation.

    For example...

    TransparentViewController *viewController = [[TransparentViewController alloc] init];
    viewController.view.frame = CGRectMake(0, 480, 320, 480);
    self.containmnetView = viewController.view;
    

    To present do this:

    [UIView animateWithDuration:0.5f animations:^{
        self.containmentView.frame = CGRectMake(0, 0, 320, 480);
    }];
    

    I hope this helps.

    0 讨论(0)
提交回复
热议问题