使用drawTextOnPath绘制矩形下方的文本
我正在尝试创建一个自定义视图,它有一个矩形,以及其上方和下方的一些文本。到目前为止,我已成功使用drawTextOnPath 方法在绘制的矩形上方获取文本。然而,应该位于矩形下方的部分却被颠倒了。我可以获得一些有关如何在矩形下方绘制文本的建议吗?
提前致谢!
I'm trying to create a custom view, which has a rectangle, and some text right above and below it. So far I am successful at getting text above the rectangle painted, using drawTextOnPath method. However, the one that should go below the rectangle, gets painted upside down. Could I get some advice on how to paint text right below the rectangle?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
文本的基线遵循您在
drawTextOnPath
中提供的路径。因此,如果文本遵循的基线(文本的底部)从右向左,则文本将会颠倒。为了使其正确向上,必须知道或测量文本的高度,然后将其向下画得更远。如果您使用的路径只是一条线,也许使用仅带有坐标的drawText
更好?The text's baseline follows the path you provide in
drawTextOnPath
. Therefore, if the baseline (the bottom of the text) that the text is to follow is going from right to left the text would be upside down. To make it the right way up have to know or measure the height of the text and then draw it that much farther down. If the path you are using is just a line, perhaps usingdrawText
with just coordinates is better?