NSString drawInRect set context

感情迁移 提交于 2019-12-23 01:16:26

问题


I draw some image in background. Sometimes my app crashes with strange error:

function signature specialization < Arg[0] = Owned To Guaranteed> of MyApp.

I checked all crashes, and I get all of them on methods that do not use context. One of them draw text. How can I specify context to draw text?

UIGraphicsBeginImageContextWithOptions(size, false, 1.0)
let ctx = UIGraphicsGetCurrentContext()
// some code
str.drawInRect(CGRectMake(floor(10 * scaleFactor), yOffset, size.width, floor(60 * scaleFactor)), withAttributes: textFontAttributes)
// code
let img = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()

Edit

I do not found any method to draw text in specific context. I use UIGraphicsPushContext(ctx) before draw text and UIGraphicsPopContext() after. https://stackoverflow.com/a/10402637/820795


回答1:


I'm not convinced that this has anything to do with drawing. The "function signature specialization" arises when there's a mistake in the Swift APIs where Objective-C needs to pass a nil parameter value to Swift, but the Swift version of this parameter is not typed as an Optional.



来源:https://stackoverflow.com/questions/31140570/nsstring-drawinrect-set-context

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