- (UIWindow *)overlayWindow {
if (!_overlayWindow) {
_overlayWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[_overlayWindow makeKeyAndVisible];
_overlayWindow.backgroundColor = [UIColor redColor];
_overlayWindow.userInteractionEnabled = NO;
_overlayWindow.frame = [UIScreen mainScreen].bounds;
[_overlayWindow addSubview:self.dimmer];
}
return _overlayWindow;
}
帧正确 - 0,0,1024,768。
该应用仅支持横向,由info.plist确认(支持的界面方向(iPad)左侧为横向,右侧为横向)。
但是,新窗口在iPad上显示为0,0,就像是纵向一样,并且相对于应用程序的其余部分定向为90度。
窗口显示如下:
[self.overlayWindow setWindowLevel:UIWindowLevelStatusBar+1];
self.overlayWindow.alpha = 1;
self.overlayWindow.userInteractionEnabled = YES;
我做错了什么?我只想创建一个新窗口并将其显示在应用程序的其余部分上,并将其定位为应用程序的主窗口。
答案 0 :(得分:0)
尝试这样:
- (UIWindow *)overlayWindow {
if (!_overlayWindow) {
_overlayWindow = [[UIWindow new];
[_overlayWindow makeKeyAndVisible];
_overlayWindow.backgroundColor = [UIColor redColor];
_overlayWindow.userInteractionEnabled = NO;
_overlayWindow.frame = [UIScreen mainScreen].bounds;
[_overlayWindow addSubview:self.dimmer];
}
return _overlayWindow;
}