【问题标题】:iOS 7 app icons showing up black as soon as I add new images添加新图像后,iOS 7 应用程序图标显示为黑色
【发布时间】:2013-11-15 21:54:10
【问题描述】:

我开始在 iOS 6 下编写这个应用程序,我设法修复了有关图像和已弃用 API 的所有问题,没有问题。

我正在创建一个新图标以支持 iOS 7 样式,但无论我是否使用资产目录和/或图像的直接路径,只要我在启动应用程序时添加新引用,我都会呈现一个黑色图标。

我显然做错了什么。

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

每当我启动时,我都会看到一个黑色图标。是否与 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 我已经完成了拖放以及单独放置每个操作。
  • 你在拖png文件吗?
  • 图片有哪些格式,.png、.jpg、.jpeg...?
  • @Abizern 是的,它们是 png。

标签: ios image ios7 icons xcode5


【解决方案1】:

首先,检查您用于应用图标的图像文件是否合适。有关详细信息,请参阅Apple's Human Interface Guidelines on App Icons,但与此问题特别相关:

避免透明。应用程序图标应该是不透明的。如果图标的 边界小于推荐的大小——或者你使用 透明度以创建“透视”区域——生成的图标可以 似乎漂浮在黑色背景上,看起来特别 在用户选择的漂亮壁纸上没有吸引力。

如果您使用透明度,例如透明背景上的黑色图像,则图标在 iOS 中可能会显示为全黑。

接下来,有几种方法可以告诉 iOS 应用程序的图标。新机制是使用资产目录; Apple 在Migrating an App Icon or Launch Image Set 上有一个指南。

旧的简单方法是将图标文件名添加到您的 Info.plist 文件 CFBundleIcons。根据 Apple 在App-Related Resources 上的文档:

无论您的应用有多少不同的图标,您都可以指定它们 使用Info.plist 文件中的CFBundleIcons 键。那的价值 key 是一个字符串数组,每个字符串包含一个文件名 你的图标。文件名可以是任何你想要的,但所有图像 文件必须是 PNG 格式,并且必须位于 您的应用程序包。 (避免使用隔行扫描的 PNG。)当系统需要时 一个图标,它选择大小最匹配的图像文件 预期用途。

【讨论】:

  • @myusuf3 我更新了答案以包括对使用透明 PNG 的警告;)
猜你喜欢
  • 2018-12-18
  • 2011-10-07
  • 1970-01-01
  • 1970-01-01
  • 2012-09-02
  • 1970-01-01
  • 2013-12-12
  • 2012-05-14
  • 1970-01-01
相关资源
最近更新 更多