0

我的第一个 viewController 中有这样的代码:

- (IBAction)showSetting:(id)sender{
   settingView = [[settingController alloc]initWithNibName:@"settingController" bundle:nil];
   settingView.modalPresentationStyle =  UIModalTransitionStyleCrossDissolve;
   [self presentModalViewController:settingView animated:YES];
}

然后在第二个视图(settingController.m)中:

- (IBAction)closeSetting:(id)sender{
   [self dismissModalViewControllerAnimated:YES];
}

我想在显示当前模式时设置背景的透明度,但它显示一个空白的黑屏。有没有人可以帮助我..

4

3 回答 3

0

请使用这个

 settingView *settingViewObj=[[settingView alloc]initWithNibName:@"settingView" bundle:nil];
    UINavigationController *nController = [[UINavigationController alloc]initWithRootViewController:settingViewObj];
   [nController setNavigationBarHidden:NO];
   [self.navigationController  presentViewController:nController animated:YES completion:nil];

但这是 iOS 6 的代码。对于 iOS 5,您可以使用

[self.navigationController  presentModelViewController:nController animated:YES];

希望这可以帮助

于 2013-05-16T09:24:32.077 回答
0

就像您有一个 rootViewController 将显示您的 settingView 。

settingView .view.backgroundColor = [UIColor clearColor];
rootViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
[rootViewController presentModalyourViewController:settingView  animated:YES];`

带有过渡的 UIModalPresentationCurrentContext

settingView .modalPresentationStyle = UIModalPresentationCurrentContext;
settingView .modalTransitionStyle = UIModalTransitionStyleCrossDissolve;

尝试这个

- (IBAction)showSetting:(id)sender{
   settingView = [[settingController alloc]initWithNibName:@"settingController" bundle:nil];
   settingView .view.backgroundColor = [UIColor clearColor];
    settingView .modalPresentationStyle = UIModalPresentationCurrentContext;
    settingView .modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self presentModalyourViewController:settingView  animated:YES];
}
于 2013-05-16T08:23:51.603 回答
0

正如上面其他人所解释的,您可以使用模态演示来做到这一点:

settingView .modalTransitionStyle = UIModalTransitionStyleCrossDissolve;

但是,如果您从后面看到不同的颜色,是因为您的窗口具有该颜色。尝试设置窗口的背景颜色(通常在 AppDelegate 上):

window?.backgroundColor = UIColor.whiteColor()

于 2016-02-24T14:54:00.997 回答