CGSize screenSize = [UIScreen mainScreen].bounds.size;
// 如果是iPhone
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) {
// 竖屏情况
if (screenSize.height > screenSize.width) {
if (screenSize.height == 568) {
NSLog(@"当前为iPhone 5/5c/5s iPod Touch5 设备");
}else if (screenSize.height == 667) {
NSLog(@"当前为iPhone6/6s设备");
}else if (screenSize.height == 736) {
NSLog(@"当前为iPhone6 Plus/iPhone6s Plus 设备");
}else {
NSLog(@"当前为iPhone4/4s 等其他设备");
}
}
// 横屏情况
if (screenSize.width > screenSize.height) {
if (screenSize.width == 568) {
NSLog(@"当前为iPhone 5/5c/5s iPod Touch5 设备");
}else if (screenSize.width == 667) {
NSLog(@"当前为iPhone6/6s设备");
}else if (screenSize.width == 736) {
NSLog(@"当前为iPhone6 Plus/iPhone6s Plus 设备");
}else {
NSLog(@"当前为iPhone4/4s 等其他设备");
}
}
}
根据屏幕判断设备型号
最新推荐文章于 2024-07-19 14:03:15 发布