[英]Black Screen in present Modal
我的拳頭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];
}
我想在顯示當前模態時設置背景的透明度,但是它顯示黑屏。 有沒有人可以幫助我..
就像您有一個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];
}
請用這個
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];
希望這可以幫助
正如上面其他人所解釋的,您可以使用以下方式通過模態演示來實現:
settingView .modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
但是, 如果您看到后面有其他顏色,那是因為窗口具有該顏色。 嘗試設置窗口的背景顏色(通常在AppDelegate上):
window?.backgroundColor = UIColor.whiteColor()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.