UIV在UIAlertView之上

swa*_*ner 3 z-index uiview uialertview ios

在我的应用程序中,使用锁定屏幕.有时显示a UIAlertView,现在当用户将应用程序发送到后台并再次将其带到前面时,UIAlertview会显示锁定屏幕上方.是否有可能UIViewController在一切之上添加一个视图,即高于UIAlertView

Vij*_*com 5

你应该有这样的

UIWindow *mySpecialWindowForLockScreen = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen] bounds]];

//"Hey iOS Please put this window above all alert view"
mySpecialWindowForLockScreen.windowLevel = UIWindowLevelAlert+100;

UIViewController *lockScreenViewController = [[UIViewController alloc]init];//Lock Screen

lockScreenViewController.view.frame = mySpecialWindowForLockScreen.bounds;

mySpecialWindowForLockScreen.rootViewController = lockScreenViewController;


// In lockScreenViewController view you can add lock screen images and other UI stuff
mySpecialWindowForLockScreen.rootViewController.view.backgroundColor = [UIColor greenColor];

[mySpecialWindowForLockScreen makeKeyAndVisible];
Run Code Online (Sandbox Code Playgroud)

每当您想要隐藏LockScreen窗口时,只需通过setHidden隐藏它:YES.