capacitor配置ios应用图标不同尺寸

打开ios/App/App/Assets.xcassets/AppIcon.appiconset/Contents.json

复制代码
​
{
  "images": [
    // iPhone 主屏幕图标(60pt,@2x和@3x)
    {
      "filename": "AppIcon-60@2x.png",
      "idiom": "iphone",
      "platform": "ios",
      "size": "60x60",
      "scale": "2x"
    },
    {
      "filename": "AppIcon-60@3x.png",
      "idiom": "iphone",
      "platform": "ios",
      "size": "60x60",
      "scale": "3x"
    },
    // iPad 主屏幕图标(83.5pt,@2x)
    {
      "filename": "AppIcon-83.5@2x.png",
      "idiom": "ipad",
      "platform": "ios",
      "size": "83.5x83.5",
      "scale": "2x"
    },
    // 设置页图标(29pt,@2x和@3x)
    {
      "filename": "AppIcon-29@2x.png",
      "idiom": "universal",
      "platform": "ios",
      "size": "29x29",
      "scale": "2x"
    },
    {
      "filename": "AppIcon-29@3x.png",
      "idiom": "universal",
      "platform": "ios",
      "size": "29x29",
      "scale": "3x"
    },
    // App Store 展示图标(1024x1024)
    {
      "filename": "AppIcon-512@2x.png",
      "idiom": "universal",
      "platform": "ios",
      "size": "1024x1024",
      "scale": "1x"
    }
  ],
  "info": {
    "author": "xcode",
    "version": 1
  }
}

也要导入相应尺寸的图片

关键参数说明:

  • size:图标逻辑尺寸(单位 pt),如 60x60 表示 60pt,AppIcon-60@2x.png这个图片需要60 * 2=120px的,所以AppIcon-60@2x.png需要120px * 120px尺寸的;AppIcon-60@3x.png需要60 * 3 = 180px,也就是需要180px * 180px的。

  • scale:缩放倍数(1x/2x/3x),实际像素尺寸 = 逻辑尺寸 × 缩放倍数(如 60x60@2x 对应 120x120 像素)

  • idiom:设备类型(iphone/ipad/universal 通用)

配置后需注意:

  1. 确保每个 filename 对应的图片文件已放入 AppIcon.appiconset 文件夹

  2. 运行 npx cap sync ios 同步到原生项目

  3. 清理 Xcode 缓存后重新构建

这样就能适配不同设备的图标显示需求了。

相关推荐
_瑞13 小时前
深入理解灵动岛
前端·ios·app
黑科技iOS上架15 小时前
分享一个开源的iOS应用AppIcon生成器
经验分享·ios
码云数智-大飞1 天前
从 OC 平滑迁移 Swift 完整方案
职场和发展·蓝桥杯
wabil2 天前
【LVGL】滑动切换页面的界面优化实践
开发语言·ios·swift
威武的花瓣2 天前
调用Page.RegisterAsyncTask()的异步页
ios·iphone
码云数智-园园2 天前
SwiftUI 6 生产落地踩坑实录
macos·objective-c·cocoa
Digitally2 天前
5 种简易方法:摩托罗拉手机数据迁移至 iPhone 17
ios·智能手机·iphone
EricStone4 天前
VibeCoding工程流程学习二:iOS项目架构
ios·vibecoding
天桥吴彦祖6 天前
判断iOS如何监听手机屏幕是否锁屏
ios
敲代码的鱼7 天前
PDF 预览与签名批注写回 支持安卓 iOS 鸿蒙 UTS插件
android·前端·ios