How to rotate text drawn by Quartz on iPhone

前端 未结 4 766
情歌与酒
情歌与酒 2020-12-30 18:37

I want to draw some texts using Quartz. Now the app draws , but I want it to show as \"0123456789\". Is there any way to show its normal orientation?

Here is my cod

4条回答
  •  悲哀的现实
    2020-12-30 19:23

    Another way to handle this would be to replace the Quartz text drawing code (from CGSelectFont() to CGContextShowTextAtPoint ()) with something like

    [text drawAtPoint:CGPointMake(0.0f, 30.0f) withFont:[UIFont fontWithName:@"Courier" size:40.0f]];
    

    where text is an NSString. On the iPhone, -drawAtPoint:withFont: automatically flips the text to account for the inverted Y axis of the UIViews.

    This approach gives you the advantage of handling a wider character set than the MacRoman encoding in the pure Quartz text drawing can. However, it is slightly slower.

提交回复
热议问题