iOS 7应用图标在添加新图片后变黑

8

我开始在iOS 6下编写这个应用程序,成功解决了与图像和弃用API相关的所有问题。

我正在创建一个新的图标以支持iOS 7风格,但无论我是使用资源目录还是直接路径到图像,只要我添加一个新的引用,每当我启动应用程序时,就会出现黑色图标。

显然我做错了什么。

这是我的资源目录,显示了所有映射的图像。它们实际上没有出现在应用程序中,我在所有iOS应用程序中都有黑色图标。

enter image description here

每次我启动时,都会得到一个黑色图标。这是否与Info.plist文件中的某些设置有关?

这是它的内容。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>en</string>
    <key>CFBundleDisplayName</key>
    <string>${PRODUCT_NAME}</string>
    <key>CFBundleExecutable</key>
    <string>${EXECUTABLE_NAME}</string>
    <key>CFBundleIcons</key>
    <dict/>
    <key>CFBundleIcons~ipad</key>
    <dict/>
    <key>CFBundleIdentifier</key>
    <string>com.neckbeardrepublic.${PRODUCT_NAME:rfc1034identifier}</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>7.0</string>
    <key>CFBundleName</key>
    <string>${PRODUCT_NAME}</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleVersion</key>
    <string>1.0</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>UIAppFonts</key>
    <array>
        <string>Lato-Black.ttf</string>
        <string>FontAwesome.ttf</string>
    </array>
    <key>UIPrerenderedIcon</key>
    <true/>
    <key>UIRequiredDeviceCapabilities</key>
    <array>
        <string>armv7</string>
    </array>
    <key>UIStatusBarHidden</key>
    <false/>
    <key>UIStatusBarHidden~ipad</key>
    <true/>
    <key>UIStatusBarTintParameters</key>
    <dict>
        <key>UINavigationBar</key>
        <dict>
            <key>Style</key>
            <string>UIBarStyleDefault</string>
            <key>Translucent</key>
            <false/>
        </dict>
    </dict>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UIViewControllerBasedStatusBarAppearance</key>
    <false/>
</dict>
</plist>

非常令人沮丧。我刚刚尝试提供具体文件,但也没有多大帮助。
有人能确定问题所在吗?

它们为什么没有显示在你的plist文件中?它们应该就在CFBundleIcons下面,你有拖放它们吗? - meda
@meda 我已经尝试过拖放和逐个放置的方法。 - Mahdi Yusuf
你在拖曳PNG文件吗? - Abizern
这些图片的格式是什么,.png、.jpg、.jpeg等等? - David Gölzhäuser
@Abizern 是的,它们是PNG格式的。 - Mahdi Yusuf
@DavidG。图片是PNG格式的。 - Mahdi Yusuf
1个回答

18
首先,检查您用于应用程序图标的图像文件是否合适。请参阅苹果公司有关应用程序图标的人机界面指南获取完整细节,但与此问题特别相关的是:

避免使用透明度。应用程序图标应该是不透明的。如果图标的边界小于建议的尺寸,或者您使用透明度来创建“透明”区域,则产生的图标可能会出现在黑色背景上而漂浮,这在用户选择的美丽壁纸上看起来特别不美观。

如果您正在使用透明度,例如在透明背景上放置黑色图像,则在iOS中该图标可能会完全呈现为黑色。

接下来,有几种方法可以告诉iOS有关您应用程序的图标。新机制是使用Asset Catalog;苹果公司有一份关于将应用程序图标或启动图像集迁移到Asset Catalog的指南。

旧的简单方法是将图标文件名添加到Info.plist文件的CFBundleIcons中。根据苹果公司有关应用程序相关资源的文档:

无论您的应用程序有多少不同的图标,都可以使用Info.plist文件中的CFBundleIcons键进行指定。该键的值是一个字符串数组,每个字符串包含一个图标的文件名。文件名可以任何您希望的名称,但所有图像文件必须以PNG格式存在于您的应用程序包的顶层目录中。(避免使用交错PNG。)当系统需要时一个图标,它会选择尺寸最接近预期使用的图像文件。


2
@myusuf3 我更新了答案,加入了警告不要使用透明PNG ;) - pix0r

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接