iPhone齐刘海屏幕的判断

注意是13.0 以后新增UIWindowScene


/** 判断是不是齐刘海屏幕系列*/
+ (BOOL)QiLiuhaiSeries
{
    // 根据安全区域判断
       if (@available(iOS 11.0, *)) {
         
           CGFloat height = 0;
          
           if (@available(iOS 13.0, *)) {
              
               NSArray *array =[[[UIApplication sharedApplication] connectedScenes] allObjects];
                                 
               UIWindowScene *windowScene = (UIWindowScene *)array[0];
              
               if (windowScene) {
                   UIWindow *window = windowScene.windows[0];
                    if (window) {
                        height = window.safeAreaInsets.bottom;
                    }
               }

           } else {
               height = [[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom;
           }
          
           return (height > 0);
          
       } else {
          
           return NO;
       }
    return NO;
}

你可能感兴趣的:(iPhone齐刘海屏幕的判断)