現今移動設備愈來愈多,蘋果爲iOS設備配備了apple-touch-icon私有屬性,添加該屬性,在iPhone,iPad,iTouch的safari瀏覽器上能夠使用添加到主屏按鈕將網站添加到主屏幕上,方便用戶之後訪問。實現方法是在HTML文檔的<head>標籤加入下面代碼便可。web
若是不想系統對圖標添加效果,能夠用apple-touch-icon-precomposed代替apple-touch-icon,這時咱們提供的圖標就要本身作圓角和高亮效果了。瀏覽器
<link rel="apple-touch-icon-precomposed" sizes="57x57" href="icon-57.png"> app
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="icon-72.png"> 測試
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="icon-114.png"> 動畫
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="icon-144.png"> 網站
添加啓動畫面spa
<link rel="apple-touch-startup-image" sizes="2048x1496" href="icon-2048x1496.png" media="screen and (min-device-width:481px) and (max-device-width:1024px) and (orientation:landscape) and (-webkit-min-device-pixel-ratio: 2)"> scala
<link rel="apple-touch-startup-image" sizes="1536x2008" href="icon-1536x2008.png" media="screen and (min-device-width:481px) and (max-device-width:1024px) and (orientation:portrait) and (-webkit-min-device-pixel-ratio: 2)"> orm
<link rel="apple-touch-startup-image" sizes="1024x748" href="icon-1024x748.png" media="screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:landscape)"> 圖片
<link rel="apple-touch-startup-image" sizes="768x1004" href="icon-768x1004.png" media="screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:portrait)">
<link rel="apple-touch-startup-image" sizes="640x920" href="icon-640x920.png" media="screen and (max-device-width: 480px) and (-webkit-min-device-pixel-ratio: 2)">
<link rel="apple-touch-startup-image" sizes="320x460" href="icon-320x460.png" media="screen and (max-device-width: 320)">
apple-touch-startup-image是用來標示啓動畫面的,但它不像apple-touch-icon能夠指定sizes來告訴設備該使用哪一個圖片(也有一種說法是在iOS5中已經支持sizes識別了,但沒有測試成功),因此只能經過media裏的設備分辨率的判斷值來識別,而iPhone Retina的分辨率值界於取值之間,因此須要經過webkit的私有屬性-webkit-min-device-pixel-ratio:2來鑑別像素密度以進行識別。
啓動畫面的圖片尺寸並不是徹底等於設備的尺寸,好比iPad2的尺寸是1024×768,但它的啓動畫面尺寸橫向是1024×748,豎向尺寸是768×1004,由於須要減去系統狀欄的高度20px,而使用的Retina屏幕的iPhone4以及iPad3則須要減去狀態欄的高度40px。
去掉Safari的一些默認控件,好比地址欄、狀態欄之類的。
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<meta name="viewport" content="width=device-width,initial-scale=1, minimum-scale=1.0, maximum-scale=1, user-scalable=no">