Iphone Single and Double pictures (navigation background increased)

Source: Internet
Author: User

Dear students and friends! Today, I want to talk about the @ 2x 2x diagram. What I know is what I understand! Although there are a lot of beginners who often make mistakes in this regard, the following is my understanding: Average (320*480 million, and the other set is a double chart, such as image@2x.png (640*960 ). Of course, when you use the image, for example, UIImage * image = [UIImage imageNamed: @ "image.png"], or UIImage * image = [UIImage imageNamed: @ "image" watermark image. I don't know how many users are using 3gs now. In the past, I had to adapt to 3gs when writing projects, so I had to prepare two sets of diagrams in the project. Currently, most projects do not need to adapt to 3gs any more, so how do you prepare the diagram in the project. First case: there are only images without @ 2 X in the project, image.png (640*960), but it is a double image. Then you can directly [UIImage imageNamed: @ "image.png" Example: when you are using a system control, the size of image.png is 640*88 double as shown in the System navigation bar,

 UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:self.viewController];      [nav.navigationBar setBackgroundImage:[UIImage imageNamed:@"image.png"] forBarMetrics:UIBarMetricsDefault];  

 

On any device, let's take a look at the effect: 3gs and iPhone 4 and above, and use a double image for processing. (It is also possible that the device cannot find the picture and cannot display it. I have never heard of it.) so, you can see the effect! Therefore, when using system controls, you may consider a problem when setting images. Check if you have also made this mistake. Case 2: only images with @ 2 x are included in the project, while images with @ 2x.png (640*960) are added after all the images in the project. How can this problem be solved? I guess you will use it like this:
UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:self.viewController];      [nav.navigationBar setBackgroundImage:[UIImage imageNamed:@"image@2x.png"] forBarMetrics:UIBarMetricsDefault];  

 

The same is the control of the processing system, the image you use this [UIImage imageNamed: @ "image@2x.png"], resulting in the same situation as the first case above. Correct usage [UIImage imageNamed: @ "image.png" later, just remove your image from @ 2x, because the system will add @ 2x to your image. The secondary image is processed as a double image. Therefore, in the case of a double graph, I and Zhou Xiaodong have the following opinions: 1. In the project, no matter the code or xib, only images without @ 2x are used as names, like this, UIImage * image = [UIImage imageNamed: @ "image.png"] 2. In a real file, a file with @ 2x is required, and a file without @ 2x is optional (If yes, it can be better displayed in xib, because xib only recognizes image previews without @ 2x)

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.