|
floatNowTimer 用原生代码实现了iOS悬浮时钟显示功能。
- <!DOCTYPE html>
- <html>
- <head>
- <title>Module Develop</title>
- <meta charset="utf-8">
- <meta name="viewport"
- content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
- <style type="text/css">
- html,
- body {
- height: 100%
- }
- body {
- background-color: #fff;
- margin: 0;
- }
- #wrap {
- height: 100%;
- position: relative;
- }
- #header {
- padding-top: 20px;
- background-color: #5082c2;
- height: 44px;
- position: relative;
- }
- #header h1 {
- font-size: 20px;
- height: 44px;
- line-height: 44px;
- margin: 0em;
- color: #fff;
- margin-left: 100px;
- margin-right: 100px;
- text-align: center;
- }
- #main {
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-box-pack: center;
- }
- a.button {
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-box-pack: center;
- -webkit-box-align: center;
- height: 32px;
- margin: 8px;
- background-color: rgba(240, 240, 240, 1.0);
- border-color: rgba(220, 220, 220, 1.0);
- border-width: 2px;
- border-style: solid;
- }
- a.active {
- background-color: rgba(240, 240, 240, 0.7);
- }
- </style>
- </head>
- <body>
- <div id="wrap">
- <div id="main">
- <br />
- <a class="button" tapmode="active" onclick="openTimeView()">显示时间</a>
- <a class="button" tapmode="active" onclick="hideTimeView()">隐藏时间</a>
- <a class="button" tapmode="active" onclick="showTimeView()">隐藏后显示时间</a>
- <a class="button" tapmode="active" onclick="closeTimeView()">关闭时间</a>
- <a class="button" tapmode="active" onclick="startPIP()">开启画中画</a>
- <a class="button" tapmode="active" onclick="stopPIP()">停止画中画</a>
- <a class="button" tapmode="active" onclick="updateStyle1()">更新样式1</a>
- <a class="button" tapmode="active" onclick="updateStyle2()">更新样式2</a>
- <br />
- </div>
- </div>
- </body>
- <script type="text/javascript">
- var demo = null;
- apiready = function () {
- demo = api.require('floatNowTimer');
- if (!demo) {
- alert("请添加模块后编译");
- return;
- }
- }
- function openTimeView() {
- demo.openTimeView({
- rect: {
- x: 50,
- y: 200,
- w: 200,
- h: 100
- },
- fixedOn: api.frameName,
- fixed: true,
- backgroundColor: '#000000',
- }, function (ret, err) {
- alert(JSON.stringify(ret)+" "+JSON.stringify(err));
- });
- }
- function hideTimeView() {
- demo.hideTimeView(function (ret, err) {
- alert(JSON.stringify(ret));
- });
- }
- function showTimeView() {
- demo.showTimeView(function (ret, err) {
- alert(JSON.stringify(ret));
- });
- }
- function closeTimeView() {
- demo.closeTimeView(function (ret, err) {
- alert(JSON.stringify(ret));
- });
- }
- function startPIP() {
- var ret = demo.startPIP();
- alert(JSON.stringify(ret));
- }
- function stopPIP() {
- var ret = demo.stopPIP();
- alert(JSON.stringify(ret));
- }
- function updateStyle1() {
- var ret = demo.updateStyle({
- backgroundColor: '#FFFFFF',
- textFontColor: '#000000',
- textFontSize: 200,
- });
- alert(JSON.stringify(ret));
- }
- function updateStyle2() {
- var ret = demo.updateStyle({
- backgroundColor: '#FFB6C1',
- textFontColor: '#DA70D6',
- textFontSize: 120,
- });
- alert(JSON.stringify(ret));
- }
- </script>
- </html>
复制代码
|
|