自定义方法中Quartz 2D的绘图文本和NSTimer

发布于 2024-09-04 00:39:15 字数 197 浏览 3 评论 0原文

我想使用quartz 2d 显示文本。每 1 秒后,文本将在不同位置随机绘制。我不知道如何将 NSTimer 与石英 2D 文本一起使用。我可以在图形上下文已经可用的情况下在drawRect方法中绘制文本。
我如何使用自定义方法 myDraw 绘制文本,该方法将在 1 秒后使用 NSTimer 调用?

如果我创建自定义方法,则图形上下文在该方法中不可用。

i want to show text using quartz 2d. Text will be drawing randomly on different position after each 1 seconds. I am not sure how i can use NSTimer with quartz 2D text. I can draw text in drawRect method where graphics context is already available.
How i will draw text using my custom method myDraw which will be called after 1 second using NSTimer?

If i create my custom Method the graphics context is not available in that method.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

狼性发作 2024-09-11 00:39:15

在您的计时器方法中使用 setNeedsDisplay 或 setNeedsDisplayInRect: ,使您的drawRect方法很快被调用。

Use setNeedsDisplay or setNeedsDisplayInRect: in your timer method, causing your drawRect method to be called soon.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文