iOS开发之获取最上层 Window

方法一:

-(UIWindow *)topLevelWindowGet

{

UIWindow *topView = [UIApplication sharedApplication].keyWindow;

for (UIWindow *win in [[UIApplication sharedApplication].windows  reverseObjectEnumerator]) {

if ([win isEqual: topView]) {

continue;

}

if (win.windowLevel > topView.windowLevel && win.hidden != YES ) {

topView =win;

}

}

return topView;

}

 

方法二:

 

UIWindow *topView = [UIApplication sharedApplication].keyWindow;

[topView endEditing:Yes];

return topView;

posted @ 2019-09-17 10:49  kawerd  阅读(2172)  评论(0编辑  收藏  举报