问题描述
我试图在状态栏和导航栏之间添加一个子视图,所以我设置了 y 位置 = 0,然后我减小了 UIApplication Keywindow 的大小,以便它可以释放顶部的空间。
导航栏向下移动,没关系。但我还需要显示正确的状态栏。 这是我的代码。
float yPosition = 0;
CGRect fr = CGRectMake(0,yPosition,UIScreen.mainScreen.bounds.size.width,40);
runningCallView.frame = fr;
[UIApplication sharedApplication].keyWindow.frame = CGRectMake(0,40,UIScreen.mainScreen.bounds.size.height-40);
[[UIApplication sharedApplication].keyWindow.rootViewController.view addSubview:runningCallView];```
Can anyone please help on this. Thank you.
解决方法
我已经解决了这个问题。 现在,我没有将 keyWindow 向下移动,而是将 rootviewController 向下移动。
[UIApplication sharedApplication].keyWindow.rootViewController.view.frame = CGRectMake(0,shiftDownwards,UIScreen.mainScreen.bounds.size.width,UIScreen.mainScreen.bounds.size.height-shiftDownwards);
并添加了一个状态栏子视图以在顶部显示一个假子视图。 此外,UiWindow 需要是子类来检测额外的 addedView 上的触摸。
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event