The current development of the project for historical reasons are written in code UI, so judging equipment size has become an unavoidable task.
This is how I judge the size at the moment.
First, define an enumeration class that contains all the dimension types:
Enumeration types for screen dimensions typedef ns_enum (Nsuinteger, Screensizetype) {iphone4size,//Iphone5size 568, Ne6psize,//736};
Then write a static function to get the current dimension type:
+ (Screensizetype) Getscreensizetype {if (kScreenBounds.size.height = = 736) {return iphone6psize;} else if (kscreenbounds . Size.Height = = 667) {return iphone6size} else if (kScreenBounds.size.height = = 568) {return iphone5size;} return iPh One4size;}
And then get this type through the macro:
#define KSCREENSIZETYPE [Publicfunction Getscreensizetype]
Finally, when used this way:
int a = Kscreensizetype = = iphone6psize? 1:0;