我的拳头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];
}
我想在显示当前模态时设置背景的透明度,但它显示一个黑色的空白屏幕。 有没有人可以帮助我..
答案 0 :(得分: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];
}
答案 1 :(得分: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];
希望这有帮助
答案 2 :(得分:0)
如上所述,您可以使用以下方式进行模态演示:
settingView .modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
但是,如果您看到来自后面的不同颜色是因为您的窗口具有该颜色。尝试设置窗口的背景颜色(通常在AppDelegate上):
window?.backgroundColor = UIColor.whiteColor()