iPhoneXR iPhone XS ,XsMax 的适配

1.机型相关参数
iPhoneX与iPhoneXs 一样, 5,8英寸, 2436*1125 3倍屏;
iPhone XR 6.1英寸, 1792 * 828 2倍屏; 326ppi
iPhoneXs Max 6.5英寸, 2688 *1242 3倍屏; 458ppi
2.机型识别

注意需要导入头文件 #import "sys/utsname.h" 才可使用

NSString * getEquipmentModel(){
    struct utsname XZgsSystemInfoSta;
    uname(&XZgsSystemInfoSta);
    NSString *deviceStr = [NSString stringWithCString:XZgsSystemInfoSta.machine encoding:NSUTF8StringEncoding];
    if([deviceStr isEqualToString:@"iPhone10,2"] || [deviceStr isEqualToString:@"iPhone10,5"])
        return@"iPhone 8 Plus";
    else if([deviceStr isEqualToString:@"iPhone10,3"] || [deviceStr isEqualToString:@"iPhone10,6"])
        return@"iPhone X";
    else if([deviceStr isEqualToString:@"iPhone11,8"] ) return@"iPhone XR";
    else if([deviceStr isEqualToString:@"iPhone11,2"] ) return@"iPhone XS";
    else if([deviceStr isEqualToString:@"iPhone11,4"] || [deviceStr isEqualToString:@"iPhone11,6"]) 
         return@"iPhone XS Max";
    else return @"other";
}

在这里如果想获取更加详细的内部编号可参考: https://www.theiphonewiki.com/wiki/Models

你可能感兴趣的:(iPhoneXR iPhone XS ,XsMax 的适配)