iOS development @2x images, etc. adapted to different resolutions of the mobile phone

Source: Internet
Author: User

Development, for example: Nanshanimage.image=[uiimage imagenamed:@ ' index_pic.png ');

In the project also saved in [email protected] picture, this figure in order to only adapt to 960*640 resolution of the phone

Note: To adapt to the Iphone5 of the relevant picture size, but also add @2x.png. Like the Welcome interface: [email protected];

And Index_pic.png is adapted to 640*320 's mobile phone, but in the code must be written in [UIImage imagenamed:@ ' index_pic.png '], so the system automatically according to the different resolution of the phone to decide whether to call [email Protected] or index_pic.png, which is automatically matched to the resolution to use which picture.

However, if written as [UIImage imagenamed:@ ' [email protected] '], then the system can not automatically determine, according to the 640*320 resolution to call Index_pic.png pictures, the system will only [email protected] This image is a picture of a control and does not automatically look for a match.

Therefore, in the development [UIImage imagenamed:@ ' index_pic.png ']; The images inside are all pictures with small resolution format names, which automatically adapts to large resolution images and calls directly.

The UIImage class handles all the work required to load a high-resolution picture into an application. When creating a new image object, simply request the standard and high-resolution versions of the picture with the same name. For example, if you have two picture files named Button.png and [email protected], simply request a picture with the following code:

uiimage* animage = [UIImage imagenamed:@ ' Button '];

Note that in IOS4 and later versions, you can omit the file extension and provide only the picture name.

Under the high-resolution display, imagenamed:, Imagewithcontentsoffile:, and Initwithcontentsoffile: method to automatically find a picture with a @2x name (note: If the @2x.png picture and the. png image must be placed under the same package in the project, you can find it automatically). If found, the picture is loaded. If you do not provide a high-resolution version of a given picture, the image object will still load the standard version of the picture resource and scale it during the painting process. If you have a high-resolution version that provides a given picture, but there is no standard version of the picture, the HD image will not be loaded under the Standard Edition display.

Description: 1,create folder references for any added folders

Create a physical path that introduces the structure of the Blue folder. Using Imagewithcontentsoffile to get pictures, @2x.png and. png must be in the same blue directory.

2,create groups for any added folders

When importing a file, it will be the logical structure, not the physical structure, the directory structure icon is as follows, the yellow folder structure, and the build group is the same, @2x.png and. png can be in different yellow folders (because there is no physical path, the referenced picture path is actually under the same path).

Note: Xib the same principle when choosing a picture to do the background! Also choose not to take @2x, this will bring your own according to the resolution to match whether to use a small map or @2x large map!

Reward

Development, for example: Nanshanimage.image=[uiimage imagenamed:@ ' index_pic.png ');

In the project also saved in [email protected] picture, this figure in order to only adapt to 960*640 resolution of the phone

Note: To adapt to the Iphone5 of the relevant picture size, but also add @2x.png. Like the Welcome interface: [email protected];

And Index_pic.png is adapted to 640*320 's mobile phone, but in the code must be written in [UIImage imagenamed:@ ' index_pic.png '], so the system automatically according to the different resolution of the phone to decide whether to call [email Protected] or index_pic.png, which is automatically matched to the resolution to use which picture.

However, if written as [UIImage imagenamed:@ ' [email protected] '], then the system can not automatically determine, according to the 640*320 resolution to call Index_pic.png pictures, the system will only [email protected] This image is a picture of a control and does not automatically look for a match.

Therefore, in the development [UIImage imagenamed:@ ' index_pic.png ']; The images inside are all pictures with small resolution format names, which automatically adapts to large resolution images and calls directly.

The UIImage class handles all the work required to load a high-resolution picture into an application. When creating a new image object, simply request the standard and high-resolution versions of the picture with the same name. For example, if you have two picture files named Button.png and [email protected], simply request a picture with the following code:

uiimage* animage = [UIImage imagenamed:@ ' Button '];

Note that in IOS4 and later versions, you can omit the file extension and provide only the picture name.

Under the high-resolution display, imagenamed:, Imagewithcontentsoffile:, and Initwithcontentsoffile: method to automatically find a picture with a @2x name (note: If the @2x.png picture and the. png image must be placed under the same package in the project, you can find it automatically). If found, the picture is loaded. If you do not provide a high-resolution version of a given picture, the image object will still load the standard version of the picture resource and scale it during the painting process. If you have a high-resolution version that provides a given picture, but there is no standard version of the picture, the HD image will not be loaded under the Standard Edition display.

Description: 1,create folder references for any added folders

Create a physical path that introduces the structure of the Blue folder. Using Imagewithcontentsoffile to get pictures, @2x.png and. png must be in the same blue directory.

2,create groups for any added folders

When importing a file, it will be the logical structure, not the physical structure, the directory structure icon is as follows, the yellow folder structure, and the build group is the same, @2x.png and. png can be in different yellow folders (because there is no physical path, the referenced picture path is actually under the same path).

Note: Xib the same principle when choosing a picture to do the background! Also choose not to take @2x, this will bring your own according to the resolution to match whether to use a small map or @2x large map!

Reward

iOS development @2x images, etc. adapted to different resolutions of the mobile phone

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.