【问题标题】:Is there any way to create an app icon in a flutter for both(android, ios)?有没有办法为两者(android,ios)创建一个应用程序图标?
【发布时间】:2020-11-20 04:59:24
【问题描述】:

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

我用过这个库,

flutter_launcher_icons

但他们只设置图标(不是为两个 android ios 自定义)。

因为如果有可能的话, 通过使用任何工具或插件。 这样更好。

【问题讨论】:

  • 是的,在 android 中它们是完美的,但 ios 呢?这对双方都有效吗
  • 我对 ios 不熟悉,但我有一个项目在 ios 中也使用相同的图像,ios 部分是由另一个人完成的,他说他使用的图像与此相同..@ shirsh shukla
  • 好的,但是你知道在 IDE 中创建或自定义图标(用于颤振)的任何插件或工具吗。像 android 使用图像资产。
  • 我没有使用上面的链接来自定义图标,也许你可以使用上面的链接自定义图标,然后将自定义图像复制粘贴到 ios 和 android@shirsh shukla 中的所需文件夹

标签: android ios flutter dart plugins


【解决方案1】:

我假设您想在两个平台(android、ios)上显示不同的启动器图标。如果是,请看看这个post

【讨论】:

  • 不,我想要一个(工具、插件或任何其他方式),他们可以快速创建或自定义两个平台(android、ios)的图标。
【解决方案2】:

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

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

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

别忘了添加可执行权限。

chmod +x flutter_app_icon_convert.sh

如果还没有安装ImageMagick镜像工具,那就安装吧。

brew install imagemagick

然后使用脚本创建 Flutter 应用图标(Android 和 iOS)。

在你的颤振项目文件夹中:

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='\033[0;31m'
GREEN='\033[0;32m'
NO_COLOR='\033[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

【讨论】:

    猜你喜欢
    • 2022-01-20
    • 2021-11-03
    • 2011-03-25
    • 1970-01-01
    • 2018-02-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多