1.今天碰到一个问题,自定义了一个CALayer,并且在layer的drayInContext绘制直线,但是绘制线的时候,log中打印出以下错误提示:
CGContextSetStrokeColorWithColor: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
找了好长时间最后在http://stackoverflow.com/questions/12400581/custom-calayer-invalid-context-0x0这里找到答案,
将原先的
CGContextSaveGState(context)与CGContextRestoreGState(context)
换成
UIGraphicsPushContext(context); 和 UIGraphicsPopContext();