问题
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?
回答1:
Maybe you need this part of code:
CGContextRef context = UIGraphicsGetCurrentContext();
回答2:
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..."
来源:https://stackoverflow.com/questions/7105506/how-to-set-a-context-to-nsstring-drawatpoint