如何设置NSString drawAtPoint的上下文?

时间:2011-08-18 09:51:25

标签: iphone ios quartz-graphics

我目前正在处理对方法的许多[NSString drawAtPoint:withFont:]函数调用,以便我可以通过单个调用绘制大量字符串,但是如何告诉方法在哪里绘制这些字符串?

如果我将CGContextRef传递给它,如何将CGContextRef设置为当前上下文怎么办?

2 个答案:

答案 0 :(得分:6)

在iOS 4及更高版本中,使用UIGraphicsPushContext(context)和UIGraphicsPopContext()包装NSString drawAtPoint调用。

See accepted answer for "Using NSStrings drawAtPoint method in place of CGContextShowGlyphsAtPoint..."

答案 1 :(得分:-1)

也许你需要这部分代码:

CGContextRef context = UIGraphicsGetCurrentContext();