开发者

Centering text drawing in Quartz

I have a pie chart and I'm placing labels like 5%, 10%, etc around the pie chart. I find the exact center point of that pie segment, by rotating, and translating my coordinate system. In the end, I basically end up with my coordinate system translated to a point, half the size of the radius of the circle, in the middle of the pie segment. When I draw my text like "100%", it starts at the correct spot like it should.

However, is there a way to justify middle somehow? For example, if I have a circle, and I translate my CTM to the center of the circle, my text would be right below the middle diameter of the circle, and a little to the right of the center diameter. I'd like to get 开发者_StackOverflow社区it right smack in the center. I didn't know if there was an "easy" way to do this. What I can think of is measuring the size of my text I am drawing, and offset the CTM by half the width, and half the height of that size before drawing text. Thanks.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜