2013-03-20 7 views
5

私は次のコードを使用してのUIViewを作成しています:UIViewのフルスクリーン

UIview* baseView = [[UIview alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; 
//self.view = baseView; 
[self.view addSubview:baseView]; 
[baseView setBackgroundColor:[UIColor blackColor]]; 
baseView.userInteractionEnabled = YES; 
baseView.alpha = 0.7; 

唯一の問題は、私はそれを全画面表示を設定するにはmainScreenオプションを使用していたとしても、それは5センチメートルを除くフルスクリーンで表示されていることですUIWindowの上部にある行。これには何らかの理由がありますか?

+0

self.viewは、インターフェイスビルダー – Alessandro

+0

から、現在のビューでは、スクリーンショットを提供することができますか? – Kunal

答えて

15

これは、[[UIScreen mainScreen] applicationFrame]が表示されている場合は、ウィンドウ枠からステータスバーのサイズを引いた値を返します。簡単な方法は次のようになり、それを修正するには

UIView* baseView = [[UIView alloc] initWithFrame:CGRectMake(0, 
                  0, 
                  [[UIScreen mainScreen] applicationFrame].size.width, 
                  [[UIScreen mainScreen] applicationFrame].size.height)]; 
//self.view = baseView; 
[self.view addSubview:baseView]; 
[baseView setBackgroundColor:[UIColor blackColor]]; 
baseView.userInteractionEnabled = YES; 
baseView.alpha = 0.7; 
+0

すごい素晴らしい答え、私はそれについても考えていませんでした。はい、ギャップはステータスバーのサイズです – Alessandro

+3

[UIScreen mainScreen] .bounds [UIScreen mainScreen] .applicationFrame –

+1

は動作していますが、タブバーとナビゲーションバーの下に表示されます。 –

関連する問題