呈现具有透明度和动画的视图控制器

Pet*_*rbo 7 animation transparency cocoa-touch uiviewcontroller ios

我正在设置self.window.rootViewController.modalPresentationStyle = UIModalPresentationCurrentContext;我的应用程序代理,以便我可以呈现视图控制器并使视图透明(请参阅此SO 问题).

这很好用,唯一的一点是我在呈现视图控制器时无法动画.有没有人得到这个工作?如果没有,我还有其他选择吗?

我提出的视图控制器是一个"演练"是由一个UIScrollViewUIPageControl是应该"悬停"在界面上,所以你可以在边缘略微看到它的背景.

Pet*_*rbo 9

我最终这样做了:

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;
Run Code Online (Sandbox Code Playgroud)