美文网首页
iPhone 刘海机型判断 (支持机型iPhoneX、iPhon

iPhone 刘海机型判断 (支持机型iPhoneX、iPhon

作者: 暗光的技术小站 | 来源:发表于2018-11-12 16:49 被阅读0次

    #import "sys/utsname.h"

    +(BOOL)getIs_iPhoneX{

        structutsnamesystemInfo;

        uname(&systemInfo);

        NSString *platform = [NSString stringWithCString: systemInfo.machine encoding:NSASCIIStringEncoding];

        if([platformisEqualToString:@"i386"] || [platformisEqualToString:@"x86_64"]) {

            // 模拟器下采用屏幕的高度来判断

            return(CGSizeEqualToSize([UIScreenmainScreen].bounds.size,CGSizeMake(375,812)) ||

                    CGSizeEqualToSize([UIScreenmainScreen].bounds.size,CGSizeMake(812,375))||

                    CGSizeEqualToSize([UIScreenmainScreen].bounds.size,CGSizeMake(414,896))||

                    CGSizeEqualToSize([UIScreenmainScreen].bounds.size,CGSizeMake(896,414)));

        }

        //真机通过设备型号判断

        return[platformisEqualToString:@"iPhone10,3"]|| [platformisEqualToString:@"iPhone10,6"] ||[platformisEqualToString:@"iPhone11,2"] || [platformisEqualToString:@"iPhone11,4"] ||[platformisEqualToString:@"iPhone11,6"] ||  [platformisEqualToString:@"iPhone11,8"] ;

    }

    相关文章

      网友评论

          本文标题:iPhone 刘海机型判断 (支持机型iPhoneX、iPhon

          本文链接:https://www.haomeiwen.com/subject/sjpcfqtx.html