-2

我试图将覆盖图像放在整个 iPhone 屏幕上(也在导航和标签栏上),但没有任何反应。viewDidLoad

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;

这是我想要得到的结果: 在此处输入图像描述

4

2 回答 2

4

由于UIWindow是 的子类UIView,因此您还可以将子视图添加到关键窗口。
这些子视图将出现在任何视图控制器之上。

UIWindow *keyWindow = [[[UIApplication sharedApplication] delegate] window];
[keyWindow addSubview:imageView];
于 2013-08-30T11:51:31.557 回答
0
imageView.frame = [[UIScreen mainScreen] applicationFrame];
[self.navigationController.view addSubview: imageView];
于 2013-08-30T11:16:27.903 回答