iOS Development Basics-Fragmentation 7

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.