我正试图将覆盖图像放在整个iPhone屏幕上(通过导航和标签栏)来自viewDidLoad
,但没有任何反应。
< / p>
self.imageView = [[UIImageView alloc]
initWithImage:[UIImage imageNamed:@"overlayimage.png"]];
UIWindow* window = [[UIApplication sharedApplication] keyWindow];
[window.rootViewController.view addSubview: imageView];
UITapGestureRecognizer * recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
recognizer.delegate = self;
[imageView addGestureRecognizer:recognizer];
imageView.userInteractionEnabled = YES;
self.imageView = imageView;
这是我想要获得的结果:
答案 0 :(得分:4)
由于UIWindow
是UIView
的子类,您还可以将子视图添加到关键窗口。
这些子视图将显示在任何视图控制器上方。
UIWindow *keyWindow = [[[UIApplication sharedApplication] delegate] window];
[keyWindow addSubview:imageView];
答案 1 :(得分:0)
imageView.frame = [[UIScreen mainScreen] applicationFrame];
[self.navigationController.view addSubview: imageView];