2016-05-24 46 views
1

我正在構建一個iOS瀏覽器應用程序。我們如何才能像Safari那樣從給定的URL中獲取書籤圖標(收藏圖標)?我試過http://www.google.com/s2/favicons?domain=www.yourdomain.com,但它只返回16x16。如何在64x64中獲得相同的圖標?獲取所需大小的圖標

enter image description here

回答

1

我建議如下算法:

  • 嘗試下載http://www.example.com/apple-touch-icon.pngAs iOS Safari looks for this URL by convention,這是一個簡單的伎倆,應該有時會奏效。
  • 否則,你需要下載和解析的頁面(如http://www.example.com),然後尋找link標記與rel屬性設置爲apple-touch-icon(如:<link rel="apple-touch-icon" href="/icons/apple-touch-icon.png">)。最後,下載圖片(例如http://www.example.com/icons/apple-touch-icon.png)。