IOS7 Development ~images.xcassets

Source: Internet
Author: User

from:http://blog.csdn.net/liufan321/article/details/9121241

Create a new project as follows:

This article shares the experience of Images.xcassets ~_~

1. Open the previously used HelloWorld project, then click and Open the images.xcassetsin the navigation area to see what's in it:]:

2. In the picture you can see that there are two dashed boxes in the middle position, and feel that you should be able to drag files directly in. OK, first prepare the resource file as shown in:

Note : For convenience, the file names of the other icons follow the naming conventions of the previous iOS icons, in addition to icon7.png .

3. Drag [email protected] to the first dashed box and drag icon7.png to the second dashed box as shown:

Note : The size of[email protected] is 58*58 pixels, and the icon7.png size is 120*120 pixels. In addition, if you drag a picture that is not in the correct size, Xcode prompts you for a warning message.

4. Click on the right side of the utility area to show the Attributes Inspector (display property inspector) icon to see the properties of the image set, tick the iOS 6.1 and Prior Sizes See what's going to happen?

5. Drag the icon-small.png,icon.png , and [email protected] order to three blank dashed boxes respectively, as shown in the following:

6. Right-click on the left side of the AppIconand select Show in Finderfrom the pop-up menu to see what you've just dragged and dragged:

7. In addition to Contents.json This file is unfamiliar, other files are just dragged into Xcode, double-click to view the contents of the contents.json file:

[HTML]View Plaincopy
  1. {
  2. "Images": [
  3. {
  4. "Size": "29x29",
  5. "Idiom": "iphone",
  6. "FileName": "Icon-small.png",
  7. "Scale": "1x"
  8. },
  9. {
  10. "Size": "29x29",
  11. "Idiom": "iphone",
  12. "FileName": "[email protected]",
  13. "Scale": "2x"
  14. },
  15. {
  16. "Size": "57x57",
  17. "Idiom": "iphone",
  18. "FileName": "Icon.png",
  19. "Scale": "1x"
  20. },
  21. {
  22. "Size": "57x57",
  23. "Idiom": "iphone",
  24. "FileName": "[email protected]",
  25. "Scale": "2x"
  26. },
  27. {
  28. "Size": "60x60",
  29. "Idiom": "iphone",
  30. "FileName": "Icon7.png",
  31. "Scale": "2x"
  32. }
  33. ],
  34. "Info": {
  35. "Version": 1,
  36. "Author": "Xcode"
  37. }
  38. }

Content at a glance ah, haha, and then do not have to deliberately remember each size of the icon should be called what the name, do not know you will, anyway, I always paste copy, hehe. After that, just drag and drop and pull it off ~_~

8. The icon is done, the start picture is OK, the specific operation is not very different, after the completion of the following:

9. Look again at the content in the finder as follows:

10. In the Finder it is not difficult to find out more than two files, respectively:[email protected] and [email protected], double-click to open the corresponding contents.json file , the contents are as follows:

[HTML]View Plaincopy
  1. {
  2. "Images": [
  3. {
  4. "Orientation": "Portrait",
  5. "Idiom": "iphone",
  6. "Extent": "Full-screen",
  7. "Minimum-system-version": "7.0",
  8. "FileName": "[email protected]",
  9. "Scale": "2x"
  10. },
  11. {
  12. "Extent": "Full-screen",
  13. "Idiom": "iphone",
  14. "Subtype": "Retina4",
  15. "FileName": "[email protected]",
  16. "Minimum-system-version": "7.0",
  17. "Orientation": "Portrait",
  18. "Scale": "2x"
  19. },
  20. {
  21. "Orientation": "Portrait",
  22. "Idiom": "iphone",
  23. "Extent": "Full-screen",
  24. "FileName": "Default.png",
  25. "Scale": "1x"
  26. },
  27. {
  28. "Orientation": "Portrait",
  29. "Idiom": "iphone",
  30. "Extent": "Full-screen",
  31. "FileName": "[email protected]",
  32. "Scale": "2x"
  33. },
  34. {
  35. "Orientation": "Portrait",
  36. "Idiom": "iphone",
  37. "Extent": "Full-screen",
  38. "FileName": "[email protected]",
  39. "Subtype": "Retina4",
  40. "Scale": "2x"
  41. }
  42. ],
  43. "Info": {
  44. "Version": 1,
  45. "Author": "Xcode"
  46. }
  47. }

11. Change the "filename": "[email protected]" and "filename": "[email protected]" to "filename": "[email Protected] " and " filename ":" [email protected] ", save and return to Xcode and see what happens?

The modified Contents.json content is as follows:

[HTML]View Plaincopy
  1. {
  2. "Images": [
  3. {
  4. "Orientation": "Portrait",
  5. "Idiom": "iphone",
  6. "Extent": "Full-screen",
  7. "Minimum-system-version": "7.0",
  8. "FileName": "[email protected]",
  9. "Scale": "2x"
  10. },
  11. {
  12. "Extent": "Full-screen",
  13. "Idiom": "iphone",
  14. "Subtype": "Retina4",
  15. "FileName": "[email protected]",
  16. "Minimum-system-version": "7.0",
  17. "Orientation": "Portrait",
  18. "Scale": "2x"
  19. },
  20. {
  21. "Orientation": "Portrait",
  22. "Idiom": "iphone",
  23. "Extent": "Full-screen",
  24. "FileName": "Default.png",
  25. "Scale": "1x"
  26. },
  27. {
  28. "Orientation": "Portrait",
  29. "Idiom": "iphone",
  30. "Extent": "Full-screen",
  31. "FileName": "[email protected]",
  32. "Scale": "2x"
  33. },
  34. {
  35. "Orientation": "Portrait",
  36. "Idiom": "iphone",
  37. "Extent": "Full-screen",
  38. "FileName": "[email protected]",
  39. "Subtype": "Retina4",
  40. "Scale": "2x"
  41. }
  42. ],
  43. "Info": {
  44. "Version": 1,
  45. "Author": "Xcode"
  46. }
  47. }

12. Select the "[email protected]" and "[email protected]" below and delete the two files by deleting the keys, as shown in the following results:

After deletion, the contents of the Finder are as follows:

13. Next we create a new image to try how to operate, we still need to prepare the footage before we start, as shown in:

Note: in order to make it easier to see the background images of different resolutions at runtime, I added text markers to the images.

14. Drag the ready three Background directly into Xcode, as shown in the following:

15. Click Universalin the Devices on the right and select Device specific, then tick the iPhone and Retina 4-inch below and uncheck the IPad, as shown below:

16. Drag the image in the lower Unassigned directly to the upper-right corner of the R4 position to set the background image used by the retina screen as shown in:

17. Click and open main.storyboard, select View Controlleron the left, and in the right File Inspector , uncheck use The AutoLayout option, as shown in:

18. From the right-hand toolbar, drag one of the Uiimageview to the View Controller Master, at the bottom of the other controls . Also adjust the size properties of the Uiimageview , as shown in:

19. Set the image used by the Uiimageview as shown in:

20. Run the HelloWorld application on a different screen emulator, and you can see the following three icons.

Ok! The first experience of images.xcassets this is the moment, now do a simple subsection:

1. A friend with previous versions of Xcode should find out that the Icon.png and default.png are not required to remember the filenames used for different resolutions since Xcode 5.

2. Xcode 5 provides a separate support for images of 4 retina screens, which solves the previous need to write special code to load different images when compatible with quad-save screens;

3. Image.xcassets easier to manage and maintain;

4. Note : Start the image of PNG pictures do not use transparent pictures, interested friends may wish to try, very ugly, hehe.

IOS7 Development ~images.xcassets

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.