【问题标题】:how to set a context to NSString drawAtPoint?如何将上下文设置为 NSString drawAtPoint?
【发布时间】:2011-08-18 09:51:24
【问题描述】:

我目前致力于将许多[NSString drawAtPoint:withFont:] 函数调用封装到一个方法,以便我可以通过一次调用绘制大量字符串,但是我如何告诉方法在哪里绘制这些字符串?

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

【问题讨论】:

    标签: iphone ios quartz-graphics


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

      也许你需要这部分代码:

      CGContextRef context = UIGraphicsGetCurrentContext();
      

      【讨论】:

      • @AlexandreCassagne 那是很久以前的事了,现在我什至可以说我可能误解了什么问题。他需要创建上下文(例如 this_CGBitmapContextCreate_),然后按照 John Lemberger 的建议推送它。 - 使用这种方法,您可以随时拥有图像。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-09-17
      • 2011-06-07
      • 1970-01-01
      • 1970-01-01
      • 2018-11-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多