Development often encounter the need to add a translucent mask, such as all kinds of tips, such as window.
add masks on UIWindow layers
Priority Level
For example, a mask can also be added to a self.navigationController.view layer or on a self.tabBarController.view layer
Self.view < Self.navigationController.view < Self.tabBarController.view < UIWindow
UIWindow: Generally as a container for UIView
Application Scenarios
You can create a window when you need to display some controls to the top, and then add space to the window
Alipay, accounting software certification interface (gesture unlock) Most of them are made with UIWindow
Attention
1. Generally do not create windows at will, do not abuse, as long as the creation is automatically added to the interface (do not addsubview ...) , if misuse of windows can lead to an application's hierarchy confusion
2.window has a level, the higher the level is displayed in the top level (keyboard level is highest)
There are 3 levels by default: Uiwindowlevelnormal (0.0) < Uiwindowlevelalert (1000.0) < Uiwindowlevelstatusbar (2000.0)
can also be customized window.windowlevel = 4000.0;
UIWindow features
As long as the creation is automatically added to the interface
System pop-up Uialertview, pop-up keyboard, to text messages, calls, power shortages are also used UIWindow
If you need a window listener Click event you need to set the frame, because there is no frame after window creation
UIWindow *window = [[UIWindow alloc] Initwithframe:[uiscreen mainscreen].bounds];
Remove window to direct window = nil in the click method;
Cover as frame is a semitransparent or transparent button for the [UIScreen Mainscreen].bounds]
UIWindow *window = [UIApplication Sharedapplication].keywindow;
[Window Addsubview:cover];
In the last case, a custom fingerprint lock window, where Touchidview is a custom view style for Xib, can be customized according to the actual needs and add agents and other methods.
#pragma mark-Add Touchidview window
-(void) popcoverview{
Setting masks
Self.coverview = [[Uiviewalloc]initwithframe:[uiscreenmainscreen].bounds];
Self.coverView.backgroundColor = [Uicolorblackcolor];
Self.coverView.alpha = 0.6;
Add Mask up window view
Self.touchidview = [[Nsbundlemainbundle] loadnibnamed:@ "Ddtouchidview" owner:selfoptions:nil].lastobject;
Self.touchidView.center =self.coverview.center;
Self.touchidView.delegate =self;
Implementing Pop-up Methods
UIWindow *window = [Uiapplicationsharedapplication].keywindow;
Window.windowlevel =uiwindowlevelnormal;
[Window AddSubview:self.coverView];
[Window AddSubview:self.touchidView];
}