how to set a context to NSString drawAtPoint?

大憨熊 提交于 2019-12-10 17:43:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!