iPhone/iPad HTML5 Canvas fillText问题

Mr.*_*ble 5 iphone html5 canvas mobile-safari ipad

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

我有以下代码.如果我使用setTimeout,似乎我只能让文本保留在页面上.如果我在加载文档后立即调用fillText,似乎会被覆盖.

还有其他人遇到过这类问题吗?

<!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>
Run Code Online (Sandbox Code Playgroud)

小智 2

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