判断是否是iphoneX

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

#import 

BOOL IsiPhoneX(void)
{
    static BOOL isiPhoneX = NO;
    static dispatch_once_t onceToken;

    dispatch_once(&onceToken, ^{
#if TARGET_IPHONE_SIMULATOR
        NSString *model = NSProcessInfo.processInfo.environment[@"SIMULATOR_MODEL_IDENTIFIER"];
#else

        struct utsname systemInfo;
        uname(&systemInfo);

        NSString *model = [NSString stringWithCString:systemInfo.machine
                                            encoding:NSUTF8StringEncoding];
#endif
        isiPhoneX = [model isEqualToString:@"iPhone10,3"] || [model isEqualToString:@"iPhone10,6"];
    });

    return isiPhoneX;
}

转载于:https://my.oschina.net/u/474872/blog/1924996

你可能感兴趣的:(判断是否是iphoneX)