Icons, Asset Catalog and Info.plist confusion

前端 未结 3 959
误落风尘
误落风尘 2021-02-09 01:21

I have an app that started life for iOS 5 and has been updated ever since. For iOS 7 I have switched over to using an Asset Catalog for all the resources, which is nice and appe

3条回答
  •  日久生厌
    2021-02-09 01:32

    When an asset catalog is compiled for iOS 6 and lower, the images are put in the root of the app bundle, as if you were just copying them the old way. When this happens, Apple names the images according to the asset name, rather than the filename, which means we can still use +[UIImage imageNamed:] to get the assets on iOS 6 and lower.

    This is true for the App Icon asset, when we have the following icons set in our asset catalog:

    enter image description here

    They become compiled like so:

    enter image description here

    As iOS 6 is still iOS 6, these files must be referenced in the Info.plist, otherwise the existing system wouldn't work. Looking in the compiled Info.plist for this test app, you see that Xcode has added CFBundleIconFiles for us and so we don't need to.

    enter image description here

    I have uploaded the test project I used to github.com/danielctull-tests/AssetTest.

提交回复
热议问题