38: Each version of the iphone resolution and image implementation principle
[Email protected]: IPhone 4s (420) Desert5, 5C and 5S (568 c7>) Desert6 (375667) Desert6+ (414736 ) [email protected]~ipad:ipad (1024x768768)
Interface size ratio:
The principle of image size implementation:
#import <UIKit/UIKit.h>typedef ns_enum (Nsinteger, Thisdeviceclass) { Thisdeviceclass_iphone, Thisdeviceclass_iphoneretina, thisdeviceclass_iphone5, thisdeviceclass_iphone6, Thisdeviceclass_ Iphone6plus, // We can add new devices when we become aware of them thisdeviceclass_i Pad, Thisdeviceclass_ipadretina, thisdeviceclass_unknown};thisdeviceclass currentdeviceclass (); Interface UIImage (Devicespecificmedia)+ (Instancetype) Imagefordevicewithname: (NSString *) fileName; @end
#import"uiimage+devicespecificmedia.h"Thisdeviceclass Currentdeviceclass () {cgfloat greaterpixeldimension= (cgfloat) fmaxf ((float) [[UIScreen Mainscreen]bounds].size.height], ((float) [[UIScreen mainscreen]bounds].size.width)]; Switch((Nsinteger) greaterpixeldimension) { Case 480: return([[[UIScreen Mainscreen]scale] >1.0) ?Thisdeviceclass_iphoneretina:thisdeviceclass_iphone); Break; Case 568: returnThisdeviceclass_iphone5; Break; Case 667: returnThisdeviceclass_iphone6; Break; Case 736: returnThisdeviceclass_iphone6plus; Break; Case 1024x768: return([[[UIScreen Mainscreen]scale] >1.0) ?Thisdeviceclass_ipadretina:thisdeviceclass_ipad); Break; default: returnThisdeviceclass_unknown; Break; }} @implementation UIImage (Devicespecificmedia)+ (NSString *) magicsuffixfordevice{Switch(Currentdeviceclass ()) { CaseThisdeviceclass_iphone:return @""; Break; CaseThisdeviceclass_iphoneretina:return @"@2x"; Break; CaseThisdeviceclass_iphone5:return @"[email protected]"; Break; CaseThisdeviceclass_iphone6:return @"[email protected]";//or some other arbitrary string: Break; CaseThisdeviceclass_iphone6plus:return @"[email protected]"; Break; CaseThisdeviceclass_ipad:return @"~ipad"; Break; CaseThisdeviceclass_ipadretina:return @"[email protected]"; Break; CaseThisdeviceclass_unknown:default: return @""; Break; }}+ (Instancetype) Imagefordevicewithname: (NSString *) filename{UIImage*result =Nil; NSString*namewithsuffix =[FileName stringbyappendingstring:[uiimage Magicsuffixfordevice]; Result=[UIImage Imagenamed:namewithsuffix]; if(!result) {Result=[UIImage Imagenamed:filename]; } returnresult;} @end
39: Several other knowledge pictures
1:nsobject Inheritance class diagram
2:sqlite3 return meaning
3: View coordinate description
4: Life cycle diagram
5:ui inheritance Diagram
6:segue list jump, about the difference between selection and accessory
iOS Development Basics-Fragmentation 7