有没有任何方法可以为两者(android、ios)创建一个应用程序图标



在android和ios中,可以选择创建或自定义图像形状、背景等。对于应用程序图标。但在一瞬间,这是不可能的。

我用过这个图书馆,

flatter_launcher_cons

但他们只设置了图标(而不是为两个android系统定制(。

因为如果在颤动中是可能的,通过使用任何工具或插件。它更好。

我假设您希望在两个平台(android、ios(上显示不同的启动器图标。如果是,请看一下这篇文章

不久前,我编写了一个sh脚本来创建我的flutter应用程序图标。现在我可以分享了,但我不知道它是否能满足你的要求,你可以试一试。

此脚本首先需要一个源1024x1024应用程序图标。

将以下脚本的内容保存为.sh文件。例如CCD_ 3。

不要忘记添加可执行权限。

chmod +x flutter_app_icon_convert.sh

如果您还没有安装ImageMagick映像工具,请安装它。

brew install imagemagick

然后使用脚本创建flutter应用程序图标(Android和iOS(。

在你的flutter项目文件夹中:

sh your_path/flutter_app_icon_convert.sh your_source_app_icon_1024x1024.png .

#!/bin/sh
# echo font color
# https://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux
#
# ANSI escape codes:
#
# Black        0;30     Dark Gray     1;30
# Red          0;31     Light Red     1;31
# Green        0;32     Light Green   1;32
# Brown/Orange 0;33     Yellow        1;33
# Blue         0;34     Light Blue    1;34
# Purple       0;35     Light Purple  1;35
# Cyan         0;36     Light Cyan    1;36
# Light Gray   0;37     White         1;37
#
#
RED='33[0;31m'
GREEN='33[0;32m'
NO_COLOR='33[0m'
convertImage() {
src=$1
srcdir=$(dirname "$src")
if test -d "$2"; then
des="$(
cd "$2" || exit
pwd
)"
build512=0
else
build512=1
des="$(
cd "${srcdir}" || exit
pwd
)/AppIcons"
fi
echo "Icons will be saved to :${GREEN}${des}${NO_COLOR}"
mkdir -p "$des"
echo 'creating ios icons...'
ios=${des}/ios/Runner/Assets.xcassets/AppIcon.appiconset
mkdir -p "$ios"
convert -resize 20x20 "$src" "$ios"/Icon-App-20x20@1x.png
convert -resize 40x40 "$src" "$ios"/Icon-App-20x20@2x.png
convert -resize 60x60 "$src" "$ios"/Icon-App-20x20@3x.png
convert -resize 29x29 "$src" "$ios"/Icon-App-29x29@1x.png
convert -resize 58x58 "$src" "$ios"/Icon-App-29x29@2x.png
convert -resize 87x87 "$src" "$ios"/Icon-App-29x29@3x.png
convert -resize 40x40 "$src" "$ios"/Icon-App-40x40@1x.png
convert -resize 80x80 "$src" "$ios"/Icon-App-40x40@2x.png
convert -resize 120x120 "$src" "$ios"/Icon-App-40x40@3x.png
convert -resize 120x120 "$src" "$ios"/Icon-App-60x60@2x.png
convert -resize 180x180 "$src" "$ios"/Icon-App-60x60@3x.png
convert -resize 76x76 "$src" "$ios"/Icon-App-76x76@1x.png
convert -resize 152x152 "$src" "$ios"/Icon-App-76x76@2x.png
convert -resize 167x167 "$src" "$ios"/Icon-App-83.5x83.5@2x.png
convert -resize 1024x1024 "$src" "$ios"/Icon-App-1024x1024@1x.png
echo 'creating android icons...'
android=${des}/android/app/src/main/res
mkdir -p "$android"
mkdir -p "$android"/mipmap-xxxhdpi
mkdir -p "$android"/mipmap-xxhdpi
mkdir -p "$android"/mipmap-xhdpi
mkdir -p "$android"/mipmap-mdpi
mkdir -p "$android"/mipmap-hdpi
convert -resize 192x192 "$src" "$android"/mipmap-xxxhdpi/ic_launcher.png
convert -resize 144x144 "$src" "$android"/mipmap-xxhdpi/ic_launcher.png
convert -resize 96x96 "$src" "$android"/mipmap-xhdpi/ic_launcher.png
convert -resize 48x48 "$src" "$android"/mipmap-mdpi/ic_launcher.png
convert -resize 72x72 "$src" "$android"/mipmap-hdpi/ic_launcher.png
echo ''
if [ $build512 = 1 ]; then
convert -resize 512x512 "$src" "$des"/Icon-App-512x512.png
else
echo 'if you want to create an extra 512x512 icon, use command:'
echo "convert -resize 512x512 $src $srcdir/Icon-App-512x512.png"
echo ''
fi
echo "${GREEN}Done${NO_COLOR}."
echo ''
}
printHelp() {
echo 'This script use "ImageMagick" image tool to convert 1024x1024 App Icon to flutter Android and iOS icons.'
echo 'So you need install "ImageMagick" first: https://imagemagick.org/script/download.php'
echo 'This script can accept 2 parameters. The first is your srouce App Icon, the size should be 1024x1024.'
echo 'The second parameter is optional and specifies the save path of the generated icons. If not specified, it will be saved to the folder where the source icon is located, and an additional 512x512 icon will be generated.'
}
if command -v convert >/dev/null 2>&1; then
if test "$1" = "-h" -o "$1" = "--help"; then
printHelp
elif test -f "$1"; then
convertImage "$1" "$2"
else
echo "${RED}Error${NO_COLOR}: please provide your 1024x1024 source app icon file."
echo ''
printHelp
fi
else
echo "${RED}Error${NO_COLOR}:ImageMagick convert image tools not installed,you can use homebrew to intall it:"
echo 'brew install imagemagick'
fi

最新更新