5

次のコードを使用して 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 オプションを使用してフルスクリーンに設定している場合でも、UIWindow の上部にある 5cm の線を除いてフルスクリーンに表示されることです。これには何か理由がありますか?

4

1 に答える 1

17

さて、これが発生する理由[[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;
于 2013-03-20T17:09:01.040 に答える