IPhone X Unity刘海适配解决方案

Unity如果未做任何处理的话,导出的IPA运行起来的效果,刘海屏这块被自己被覆盖掉

IPhone X Unity刘海适配解决方案_第1张图片

解决方案

在导出的UnityAppController.mm文件中找到-(BOOL)didFinishWithLaunchingWithOptions:(NSDictionary*)launchOptions 方法

竖屏(参数刚好移出刘海的区域)

参数自己可以调节

//    _window         = [[UIWindow alloc] initWithFrame: [UIScreen mainScreen].bounds];
 
    CGRect winSize = [UIScreen mainScreen].bounds;
    //IPHONEX
    if (winSize.size.height / winSize.size.width > 2) 
    {
        winSize.size.height -= 32;
        winSize.origin.y = 32;
    }  
    _window = [[UIWindow alloc] initWithFrame: winSize]; 

横屏(参数刚好移出刘海的区域)

参数自己可以调节

//    _window         = [[UIWindow alloc] initWithFrame: [UIScreen mainScreen].bounds];

    CGRect winSize = [UIScreen mainScreen].bounds;
    //IPHONEX
    if (winSize.size.width/ winSize.size.height> 2) 
    {
        winSize.size.width-= 32;
        winSize.origin.x = 32; 
    } 
    _window = [[UIWindow alloc] initWithFrame: winSize]; 

你可能感兴趣的:(Unity3D,IOS,IPONEX)