Currently developed projects are written in code for historical reasons, so judging device size is an unavoidable task.
So far I have judged the size.
First, you define an enumeration class that contains all the dimension types:
//Screen Size enumeration typetypedefNs_enum (Nsuinteger, Screensizetype) {iphone4size,//480Iphone5size,//568Iphone6size,//667Iphone6psize,//736};
Then write a static function to get the current size type:
+ (Screensizetype) Getscreensizetype {if(KScreenBounds.size.height = =736) {returnIphone6psize; }Else if(KScreenBounds.size.height = =667) {returnIphone6size; }Else if(KScreenBounds.size.height = =568) {returnIphone5size; }returnIphone4size;}
Then get this type by macro:
#define Kscreensizetype [Publicfunction Getscreensizetype]
Finally, use this when:
int 1 0;
It's not clear how everyone is going to make it. I hope we can comment on the discussion.
[IOS] Code best practices Discussion for device screen judgment