2012-11-13 58 views
1

我在製作登錄屏幕。我有以下故事板。 enter image description here故事板視圖控制器中的透明背景

我在做的代碼是。如果設備上存儲了用戶名和密碼。比passViewController彈出。其他登錄視圖控制器彈出。這工作正常。

我的問題是,LoginViewController和PassViewController應該有一個透明的背景。我知道如何用單個xib文件做到這一點,但我想在故事板中做到這一點,以便我可以使用Login和Passviewcontroller中的segues到nextController。目前我正在使用代碼進行此操作。

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; 
     UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"LoginViewController"]; 
     vc.view.backgroundColor = [UIColor clearColor]; 
     self.modalPresentationStyle = UIModalPresentationCurrentContext; 
     [self presentModalViewController:vc animated:YES]; 

任何人都可以幫助我如何實現這一目標。

親切的問候。

回答

1

如果我的理解是正確的,你只需要點擊你的視圖控制器的視圖,例如你的LoginViewController的視圖。這是控制器視圖層次結構中的第一個視圖。然後在屬性檢查器中,在屏幕右側,可以將視圖的背景色設置爲「清除顏色」。那是你在找什麼?

+0

是的,我做到了,但我得到了一個黑色的背景。 – Steaphann

+0

好吧,我現在可以看到你正在嘗試做什麼..你需要將你的圖像設置爲你的viewControllers視圖中的背景圖像。你可以這樣做:'self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@「image name」]];' – NikosM

+0

是的,這可以是一個解決方案。但我希望它顯示像一個alertview,這就是爲什麼我希望它是透明的 – Steaphann