IOS HTML5添加图标到主屏幕

适配屏幕大小并且去掉safari的地址栏,状态栏

<meta name="viewport" content="width=device-width,
		initial-scale=1,maximum-scale=1,user-scalable=no">
<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">

设置添加到主屏幕的图标

apple-touch-icon 与 apple-touch-icon-precomposed都可以设置图标,那么,多出来的precomposed 表示神马意思呢?没有precomposed 代码,一些包括圆角,阴影,反光的特效便会自动添加到生成的本地app 的logo 中。是自iOS 2.0 开始的,但如今随着iOS7 的出现,已经变得可有可无了;

<!-- 自定义各种尺寸图标 ,这里偷懒一下就用一张 -->
<link rel="apple-touch-icon-precomposed" 
      sizes="144x144" href="imgs/icon.png">
<link rel="apple-touch-icon-precomposed" 
      sizes="114x114" href="imgs/icon.png">
<link rel="apple-touch-icon-precomposed" 
      sizes="72x72" href="imgs/icon.png">
<link rel="apple-touch-icon-precomposed" 
      sizes="57x57" href="imgs/icon.png">

设置启动页

目前在ios9上还无法显示,具体原因还没找到。如果你知道解决方法,劳烦告诉一下我,多谢!

<!-- 添加启动页 ios9暂无法显示 -->
<!-- iPhone -->
<link href="imgs/splash-320x460.png"
      media="(device-width: 320px) and (device-height: 480px) 
          and (-webkit-device-pixel-ratio: 1)"
      rel="apple-touch-startup-image">
<!-- iPhone (Retina) -->
<link href="imgs/splash-640x920.png"
      media="(device-width: 320px) and (device-height: 480px) 
          and (-webkit-device-pixel-ratio: 2)"
      rel="apple-touch-startup-image">
<!-- iPhone 5 -->
<link href="imgs/splash-640x1096.png"
      media="(device-width: 320px) and (device-height: 568px) 
          and (-webkit-device-pixel-ratio: 2)"
      rel="apple-touch-startup-image">
<!-- iOS 8 iPhone 6 (portrait) -->
<link href="imgs/splash-750x1294.png"
      media="(device-width: 375px) and (device-height: 667px) 
          and (orientation: portrait) 
          and (-webkit-device-pixel-ratio: 2)"
      rel="apple-touch-startup-image">
<!-- iOS 8 iPhone 6 (landscape) -->
<link href="imgs/splash-710x1334.jpg"
      media="(device-width: 375px) and (device-height: 667px) 
          and (orientation: landscape) 
          and (-webkit-device-pixel-ratio: 2)"
      rel="apple-touch-startup-image" >
<!-- iOS 8 iPhone 6 Plus (portrait) -->
<link href="imgs/splash-1242x2148.jpg"
      media="(device-width: 414px) and (device-height: 736px) 
      	  and (orientation: portrait) 
      	  and (-webkit-device-pixel-ratio: 3)"
      rel="apple-touch-startup-image" >
<!-- iOS 8 iPhone 6 Plus (landscape) -->
<link href="imgs/splash-1182x2208.jpg"
      media="(device-width: 414px) and (device-height: 736px) 
          and (orientation: landscape) 
          and (-webkit-device-pixel-ratio: 3)"
      rel="apple-touch-startup-image" >
<!-- iPad (portrait) -->
<link href="apple-touch-startup-image-768x1004.png"
      media="(device-width: 768px) and (device-height: 1024px)
         and (orientation: portrait)
         and (-webkit-device-pixel-ratio: 1)"
      rel="apple-touch-startup-image">
<!-- iPad (landscape) -->
<link href="apple-touch-startup-image-748x1024.png"
      media="(device-width: 768px) and (device-height: 1024px)
         and (orientation: landscape)
         and (-webkit-device-pixel-ratio: 1)"
      rel="apple-touch-startup-image">
<!-- iPad (Retina, portrait) -->
<link href="apple-touch-startup-image-1536x2008.png"
      media="(device-width: 768px) and (device-height: 1024px)
         and (orientation: portrait)
         and (-webkit-device-pixel-ratio: 2)"
      rel="apple-touch-startup-image">
<!-- iPad (Retina, landscape) -->
<link href="apple-touch-startup-image-1496x2048.png"
      media="(device-width: 768px) and (device-height: 1024px)
         and (orientation: landscape)
         and (-webkit-device-pixel-ratio: 2)"
      rel="apple-touch-startup-image">

弹出添加到主屏幕提示

这里用到了第三方插件:GitHub - cubiq/add-to-homescreen: Add to home screen call-out for mobile devices    支持android、ios。详细用法自己去查看,以下只是在ios上简单的使用。

<!-- 添加提示插件 -->
<link rel="stylesheet" type="text/css" 
    href="addToHomescreen/css/addtohomescreen.css">
<script src="addToHomescreen/js/addtohomescreen.js"></script>

<script>
    <!-- 清除session,每次都弹出提示 -->
    addToHomescreen.removeSession();
    addToHomescreen();
</script>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

1024小神

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值