3

I currently working on encapsulation many [NSString drawAtPoint:withFont:] function calls to a method so that I could draw lots of strings by a single call, but how can I tell the method where to draw these strings?

What if I pass a CGContextRef to it, how to set a CGContextRef as current context?

Alexandre Cassagne
  • 2,384
  • 23
  • 40
CarmeloS
  • 7,868
  • 8
  • 56
  • 103

2 Answers2

6

On iOS 4 and later, wrap the NSString drawAtPoint calls with UIGraphicsPushContext(context) and UIGraphicsPopContext().

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

Community
  • 1
  • 1
John Lemberger
  • 2,689
  • 26
  • 25
-1

Maybe you need this part of code:

CGContextRef context = UIGraphicsGetCurrentContext();
Serhii Mamontov
  • 4,942
  • 22
  • 26
  • 1
    @AlexandreCassagne it was long ago and even I can say now what maybe I misunderstood question. He need to create context (for example this _ CGBitmapContextCreate_) and then push it as John Lemberger suggested. - With this approach you can have image at any moment. – Serhii Mamontov Dec 25 '15 at 21:47