iOS 获取正在使用的UIWindow

OC:

    - (UIView*)getTopView{

        UIView*topView =nil;

        UIApplication *app = [UIApplication sharedApplication];

        if(app) {

            UIWindow *topWindow = [[[UIApplication sharedApplication].windows  sortedArrayUsingComparator:^NSComparisonResult(UIWindow *win1, UIWindow *win2) {

                returnwin1.windowLevel- win2.windowLevel;

            }]lastObject];

        topView = [[topWindowsubviews]lastObject];

    }

        return topView;

}

你可能感兴趣的:(iOS 获取正在使用的UIWindow)