I am trying to put overlay image over whole iPhone screen (over navigation and tabbar also) from viewDidLoad
but nothing happens.
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;
This is the result that I am trying to get:
Since UIWindow
is a subclass of UIView
, you can also add subviews to the key window.
These subviews will appear above any view controller.
UIWindow *keyWindow = [[[UIApplication sharedApplication] delegate] window];
[keyWindow addSubview:imageView];