I think I'm missing something simple here. I need to create a semi-transparent UIImageView that covers the entire screen including the navigation toolbar. How do I do this?
This is what I'm trying to do ...
This is a possible solution:
UIImage *image=[UIImage imageNamed:@"whatever.png"];
UIImageView *overlay=[[UIImageView alloc] initWithImage:image];
overlay.alpha=0.5;
[[[[UIApplication sharedApplication] delegate] window] addSubview:overlay];
EDIT:
[overlay release]
. To focus the above answer a little bit, you just need to be clear on how views clip to what parts of the device's screen that they "own".
The key point is that in a navigation view, the Navigation bar itself is not part of your [myController view]
- your view controller's view is everything below the bar and anything you do in that view clips to the rectangle below that bar.
The bar is, however, part of your [myAppDelegate window]
. The window is essentially the entire screen of your device, while the views are sub portions responsible for managing their specific bounds. So calling [[myAppDelegate window] addSubView:]
will display above the bar where [[myViewController view] addSubView:]
will not.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.