iPhone / iPad HTML5 Canvas fillText问题 [英] iPhone/iPad HTML5 Canvas fillText problem

查看:164
本文介绍了iPhone / iPad HTML5 Canvas fillText问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用iPhone或iPad时,我在画布上遇到了奇怪的问题。
文本被正确绘制(很少),或者它被绘制为倒置,或者它根本不绘制。
当文本确实可以绘制时,当旋转iPhone / Pad时,它会被擦除。

I'm having strange issues with text on a canvas when using an iPhone or iPad. Either the text gets drawn properly (rarely), or it gets drawn upside down, or it doens't get drawn at all. When the text does manage to get drawn, it is wiped when the iPhone/Pad is rotated.

我有以下代码。看来,我只能得到文本留在页面上,如果我使用setTimeout。它似乎被绘制,如果我调用fillText一旦文档加载。

I have the following code. It seems that I can only get the text to stay on the page at all if I use a setTimeout. It seems to be drawn over if I call fillText as soon as the document is loaded.

有人遇到这种问题吗?

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<script src="http://code.jquery.com/jquery-1.4.1.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        //draw_b();
        setTimeout('draw_b()', 500); ;
    });

    function draw_b() {
        var b_canvas = document.getElementById("cv");
        var context = b_canvas.getContext("2d");
        context.fillText("Belated hello world", 50, 50);
    }
</script>
</head>
<body>
<canvas id="cv" width="300" height="225"></canvas>

</body>
</html>


推荐答案

我有同样的问题,
早期版本(3.2)不支持HTML5 Canvas filltext,
您可以使用替代API,例如stroketext来修复此问题: http://www.netzgesta.de/dev/text/#canvas_api

这篇关于iPhone / iPad HTML5 Canvas fillText问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆