简体   繁体   English

添加到主屏幕的iOS图标变黑

[英]iOS icon for Add to Home Screen turns black

I'm not terribly familiar with the code to add icons for iOS (and Android) when you select "Add to Home Screen", but I used the following, based on what I read: 当你选择“添加到主屏幕”时,我并不十分熟悉为iOS(和Android)添加图标的代码,但我根据我读到的内容使用了以下内容:

    <link rel="apple-touch-icon-precomposed" href="http://www.redtypewriter.com/wp-content/uploads/2014/03/57.jpg"/>  
    <link rel="apple-touch-icon-precomposed" sizes="72x72" href="http://www.redtypewriter.com/wp-content/uploads/2014/03/72.jpg"/>  
    <link rel="apple-touch-icon-precomposed" sizes="114x114" href="http://www.redtypewriter.com/wp-content/uploads/2014/03/114.jpg"/>  

The code seems to work, but after I add it to my home screen, after some time, the icon disappears and I'm left with a black square in place of the icon? 代码似乎工作,但在我将它添加到我的主屏幕后,一段时间后,图标消失,我留下一个黑色方块代替图标? What's happening? 发生了什么? The site is: http://www.redtypewriter.com/ if you want to take a look, and I am using a custom WordPress theme. 该网站是: http//www.redtypewriter.com/如果你想看看,我正在使用自定义WordPress主题。

Thanks! 谢谢!

There are two mains reasons to get black icons: 获得黑色图标有两个主要原因:

  • Using JPG pictures (iOS prefers PNG) 使用JPG图片(iOS更喜欢PNG)
  • Using PNG with transparent regions. 使用带透明区域的PNG。 iOS fills transparent regions with black. iOS用黑色填充透明区域。

In your case, this is because your pictures are in JPG format instead of PNG. 在您的情况下,这是因为您的图片是JPG格式而不是PNG。

With you original pictures, I observed three issues: 有了原始图片,我发现了三个问题:

  • The black icon, as you described it. 正如你所描述的那样,黑色图标。
  • It took some time for my device to show the icon (eg. when adding to the home screen). 我的设备花了一些时间来显示图标(例如,添加到主屏幕时)。 During the first few seconds, I only saw default icons. 在最初的几秒钟内,我只看到了默认图标。 This is not that unusual, but I was a bit surprised. 这不是那么不寻常,但我有点惊讶。
  • When bookmarking, my device didn't use your icons but another one: 书签时,我的设备没有使用您的图标,而是另一个: 书签中的“RT”图标

As soon as I converted them to PNG and change the HTML code accordingly, all issues were fixed at once. 只要我将它们转换为PNG并相应地更改HTML代码,所有问题都会立即修复。

In addition, you don't define enough pictures . 此外, 您没有定义足够的图片 For example, your icon won't look great on a Retina iPad. 例如,您的图标在Retina iPad上看起来不太好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM