```
typedef NS_ENUM(char, iPhoneModel){ //0~3
iPhone4,//320*480
iPhone5,//320*568
iPhone6,//375*667
iPhone6Plus,//414*736
UnKnown
};
- (iPhoneModel)iPhonesModel {
CGRect rect = [[UIScreen mainScreen] bounds];
CGFloat width = rect.size.width;
CGFloat height = rect.size.height;
//get current interface Orientation
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
//unknown
if (UIInterfaceOrientationUnknown == orientation) {
return UnKnown;
}
if (UIInterfaceOrientationPortrait == orientation) {
if (width == 320.0f) {
if (height == 480.0f) {
return iPhone4;
} else {
return iPhone5;
}
} else if (width == 375.0f) {
return iPhone6;
} else if (width == 414.0f) {
return iPhone6Plus;
}
}else if (UIInterfaceOrientationLandscapeLeft == orientation || UIInterfaceOrientationLandscapeRight == orientation) {
//landscape
if (height == 320.0) {
if (width == 480.0f) {
return iPhone4;
} else {
return iPhone5;
}
} else if (height == 375.0f) {
return iPhone6;
} else if (height == 414.0f) {
return iPhone6Plus;
}
}
return UnKnown;
}
```
网友评论