7

self.window.rootViewController.modalPresentationStyle = UIModalPresentationCurrentContext;在我的 Application Delegate 中进行设置,以便我可以呈现一个视图控制器并使视图透明(参见这个 SO question)。

这很好用,唯一的说明是当视图控制器出现时我无法动画。有没有人让这个工作?如果没有,我还有什么其他选择?

我展示的视图控制器是一个“演练”,它由一个UIScrollView和组成UIPageControl,它应该“悬停”在界面上,这样你就可以在边缘稍微看到它的背景。

4

2 回答 2

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;
于 2013-04-03T17:28:05.350 回答
0

您可以使用基本视图控制器中存在的包含视图。代替呈现模态,将包含视图的定位设置为动画以模拟模态呈现。

例如...

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

演示这样做:

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

我希望这有帮助。

于 2013-04-03T15:24:42.030 回答