#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"] ;
}
网友评论