[UIApplication keyWindow]
The application's key window. (read-only)
@property(nonatomic, readonly) UIWindow *keyWindow
Discussion of [UIApplication keyWindow]
This property holds the
UIWindow
object in the windows
array that is most recently sent the makeKeyAndVisible
message.
Example of [UIApplication keyWindow]
id rootVC = [[[[[UIApplication sharedApplication] keyWindow] subviews] objectAtIndex:0] nextResponder];
Example of [UIApplication keyWindow]
UIWindow* window = [UIApplication sharedApplication].keyWindow;
if (!window)
window = [[UIApplication sharedApplication].windows objectAtIndex:0];
[[[window subviews] objectAtIndex:0] addSubview:myView];
Example of [UIApplication keyWindow]
#import "UIApplication+WindowOverlay.h"
@implementation UIApplication(WindowOverlay)
-(UIView *)baseWindowView{
if (self.keyWindow.subviews.count > 0){
return [self.keyWindow.subviews objectAtIndex:0];
}
return nil;
}
-(void)addWindowOverlay:(UIView *)view{
[self.baseWindowView addSubview:view];
}
@end