在 XCode 中更改目标图标
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10756123/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Change Icon of Target in XCode
提问by Matt Hudson
I noticed yesterday that my targets suddenly had icons (not the default A icon). However, I can't figure out what setting it was that changed it and it has now changed back to default. I changed all of the icon settings in the Info.plist, to no avail.
我昨天注意到我的目标突然有了图标(不是默认的 A 图标)。但是,我不知道是什么设置改变了它,现在它又变回了默认值。我更改了 Info.plist 中的所有图标设置,但无济于事。
回答by Ashley Mills
Did you add icon.png
to the root folder of your project? I think that would do it.
您是否添加icon.png
到项目的根文件夹中?我认为那会做到。
回答by A-Live
To reset the targets icons
重置目标图标
- try to find in the project all the images with the icon name from
info.plist
; - check the files
Target Membership
(File Inspector section)
- 尝试在项目中找到所有带有图标名称的图像
info.plist
; - 检查文件
Target Membership
(文件检查器部分)
They don't have to be in the project root. If there're several icon files at different project folders, each icon is a member of it's own target, then you have different target icons with the same icon name (and naturally the only icon file is copied to the bundle root).
它们不必位于项目根目录中。如果在不同的项目文件夹中有多个图标文件,每个图标都是它自己目标的成员,那么您将拥有具有相同图标名称的不同目标图标(自然,唯一的图标文件被复制到包根目录)。
回答by MUH Mobile Inc.
In the TARGET-info.plist, add the key Icon files(CFBundleIconFiles). The key "Icon files (iOS 5)" is not enough.
在 TARGET-info.plist 中,添加关键图标文件(CFBundleIconFiles)。关键的“图标文件(iOS 5)”是不够的。
The value should be "icon.png" unless you have named your icon differently.
除非您对图标进行了不同的命名,否则该值应为“icon.png”。
回答by rvijay007
The issue has to do with the Info.plist not being created correctly initially. When the app icons are set in the Summary Tab, it writes to Icon Files (iOS5) Dictionary in the TARGET-Info.plist (Raw Key: CFBundleIcons). While this is recognized on devices and the simulator to store the icon information, it is not understood by XCode. Instead, we need to rename this key to Icon Files (Raw Key: CFBundleIconFiles). Renaming this will reset the app icons to be empty, so drag the icon files into their respective spots on the summary tab. Now, the icons will be set for the Target and Product (if the Product icon is not showing, Build and Restart XCode).
该问题与最初未正确创建 Info.plist 有关。在摘要选项卡中设置应用程序图标后,它会写入 TARGET-Info.plist 中的图标文件 (iOS5) 字典(原始键:CFBundleIcons)。虽然这在设备和模拟器上被识别以存储图标信息,但 XCode 无法理解。相反,我们需要将此键重命名为 Icon Files(原始键:CFBundleIconFiles)。重命名这会将应用程序图标重置为空,因此将图标文件拖到摘要选项卡上的相应位置。现在,将为目标和产品设置图标(如果产品图标未显示,则构建并重新启动 XCode)。
Then go back to the Info.plist and you will see entries for BOTH CFBundleIcons (iOS 5) and CFBundleIconFiles (additional key also called UIPrerenderedIcon). Delete the CFBundleIcons (the iOS5 one) as this is redundant.
然后返回 Info.plist,您将看到 BOTH CFBundleIcons (iOS 5) 和 CFBundleIconFiles(附加键也称为 UIPrerenderedIcon)的条目。删除 CFBundleIcons(iOS5 中的一个),因为这是多余的。
Launch Images have to have very specific names, so these will not be in the Info.plist.
启动图像必须具有非常具体的名称,因此这些名称不会出现在 Info.plist 中。