在 Cordova/PhoneGap 中生成 iOS 和 Android 图标 [英] Generating iOS and Android icons in Cordova / PhoneGap
问题描述
我有一个新创建的 Cordova 项目,具有以下 config.xml
设置(使用来自 http://docs.phonegap.com/en/edge/config_ref_images.md.html).我还添加了 2 个平台(iOS 和 Android).
I have a freshly created Cordova project with the following config.xml
setup (used the instructions from http://docs.phonegap.com/en/edge/config_ref_images.md.html). I also added 2 platforms (iOS and Android).
当我运行 cordova run ios
或 cordova run android
时,项目仍然具有默认的 Cordova 图标.我从文档中了解到,Corodva 应该根据我在 config.xml
中提供的 icon.png
自动创建图标.
When I run either cordova run ios
or cordova run android
, the project still has the default Cordova icons. My understanding from the documentation is that Corodva is supposed to create the icons automatically based in the icon.png
I supplied in the config.xml
.
config.xml
:
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.testapp" version="1.1.2" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>SingleApp</name>
<preference name="DisallowOverscroll" value="true" />
<preference name="AutoHideSplashScreen" value="false" />
<preference name="Orientation" value="portrait" />
<preference name="Fullscreen" value="false" />
<preference name="target-device" value="handset" />
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="dev@cordova.apache.org" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<access origin="*" />
<icon src="icon.png" />
</widget>
推荐答案
我编写了一个脚本,使用 ImageMagick 为cordova 自动生成图标:
I wrote a script that auto generates icons for cordova using ImageMagick:
https://github.com/AlexDisler/cordova-icon
要使用它,请创建一个icon.png"文件并将其放在项目的根文件夹中,然后运行:
To use it, create an "icon.png" file and place it in the root folder of your project, then run:
cordova-icon
它会为您的项目拥有的平台生成所有必需的图标.
and it will generate all the required icons for the platforms your project has.
您还可以将其配置为您的cordova 项目中的一个钩子,以便在您每次基于您添加的icon.png 构建项目时生成图标.(自述文件中的说明).
You can also configure it as a hook in your cordova project so the icons will be generated every time you build the project based on the icon.png you've added. (instructions in the readme).
这篇关于在 Cordova/PhoneGap 中生成 iOS 和 Android 图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!